Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion plugins/hls-tactics-plugin/src/Wingman/Naming.hs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,29 @@ mkGoodName in_scope (mkTyName -> tn)
. foldMap (\n -> bool (pure n) mempty $ check n)
$ tn <> fmap (<> "'") tn
where
check n = S.member (mkVarOcc n) in_scope
check n = S.member (mkVarOcc n) $ illegalNames <> in_scope


illegalNames :: Set OccName
illegalNames = S.fromList $ fmap mkVarOcc
[ "case"
, "of"
, "class"
, "data"
, "do"
, "type"
, "if"
, "then"
, "else"
, "let"
, "in"
, "mdo"
, "newtype"
, "proc"
, "rec"
, "where"
]



------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions plugins/hls-tactics-plugin/test/CodeAction/DestructSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec = do
destructTest "b" 7 10 "DestructTyFam"
destructTest "b" 7 10 "DestructDataFam"
destructTest "b" 17 10 "DestructTyToDataFam"
destructTest "t" 6 10 "DestructInt"

describe "layout" $ do
destructTest "b" 4 3 "LayoutBind"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Data.Int

data Test = Test Int32

test :: Test -> Int32
test (Test in') = _w0

7 changes: 7 additions & 0 deletions plugins/hls-tactics-plugin/test/golden/DestructInt.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Data.Int

data Test = Test Int32

test :: Test -> Int32
test t = _