Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wingman: Don't use keywords for variable names #2717

Merged
merged 2 commits into from
Feb 19, 2022
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.
Jump to
Jump to file
Failed to load files.
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 = _