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

Don't suggest -Wno-deferred-out-of-scope-variables #4441

Merged
merged 1 commit into from
Nov 3, 2024
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
8 changes: 6 additions & 2 deletions plugins/hls-pragmas-plugin/src/Ide/Plugin/Pragmas.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,13 @@ suggestDisableWarning Diagnostic {_code}
pure ("Disable \"" <> w <> "\" warnings", OptGHC w)
| otherwise = []

-- Don't suggest disabling type errors as a solution to all type errors
warningBlacklist :: [T.Text]
warningBlacklist = ["deferred-type-errors"]
warningBlacklist =
-- Don't suggest disabling type errors as a solution to all type errors.
[ "deferred-type-errors"
-- Don't suggest disabling out of scope errors as a solution to all out of scope errors.
, "deferred-out-of-scope-variables"
]

-- ---------------------------------------------------------------------

Expand Down
7 changes: 6 additions & 1 deletion plugins/hls-pragmas-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,16 @@ codeActionTests' =
_ -> assertFailure $ "Expected one code action, but got: " <> show cas
liftIO $ (ca ^. L.title == "Add \"NamedFieldPuns\"") @? "NamedFieldPuns code action"
executeCodeAction ca
, goldenWithPragmas pragmasSuggestPlugin "doesn't suggest disabling type errors" "DeferredTypeErrors" $ \doc -> do
, goldenWithPragmas pragmasDisableWarningPlugin "doesn't suggest disabling type errors" "DeferredTypeErrors" $ \doc -> do
_ <- waitForDiagnosticsFrom doc
cas <- map fromAction <$> getAllCodeActions doc
liftIO $ "Disable \"deferred-type-errors\" warnings" `notElem` map (^. L.title) cas @? "Doesn't contain deferred-type-errors code action"
liftIO $ length cas == 0 @? "Expected no code actions, but got: " <> show cas
, goldenWithPragmas pragmasDisableWarningPlugin "doesn't suggest disabling out of scope variables" "DeferredOutOfScopeVariables" $ \doc -> do
_ <- waitForDiagnosticsFrom doc
cas <- map fromAction <$> getAllCodeActions doc
liftIO $ "Disable \"deferred-out-of-scope-variables\" warnings" `notElem` map (^. L.title) cas @? "Doesn't contain deferred-out-of-scope-variables code action"
liftIO $ length cas == 0 @? "Expected no code actions, but got: " <> show cas
]

completionTests :: TestTree
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module DeferredOutOfScopeVariables where

f :: ()
f = let x = Doesn'tExist
in undefined
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module DeferredOutOfScopeVariables where

f :: ()
f = let x = Doesn'tExist
in undefined
Loading