Skip to content

Commit 047ffc3

Browse files
authored
Don't suggest disabling type errors (#2061)
* Add a failing test for #2032 * Don't suggest -Wno-deferred-type-errors Fixes #2032
1 parent 2fef041 commit 047ffc3

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

Diff for: plugins/hls-pragmas-plugin/src/Ide/Plugin/Pragmas.hs

+7-1
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,16 @@ suggest dflags diag =
8181

8282
suggestDisableWarning :: Diagnostic -> [PragmaEdit]
8383
suggestDisableWarning Diagnostic {_code}
84-
| Just (J.InR (T.stripPrefix "-W" -> Just w)) <- _code =
84+
| Just (J.InR (T.stripPrefix "-W" -> Just w)) <- _code
85+
, w `notElem` warningBlacklist =
8586
pure ("Disable \"" <> w <> "\" warnings", OptGHC w)
8687
| otherwise = []
8788

89+
-- Don't suggest disabling type errors as a solution to all type errors
90+
warningBlacklist :: [T.Text]
91+
-- warningBlacklist = []
92+
warningBlacklist = ["deferred-type-errors"]
93+
8894
-- ---------------------------------------------------------------------
8995

9096
-- | Offer to add a missing Language Pragma to the top of a file.

Diff for: plugins/hls-pragmas-plugin/test/Main.hs

+7
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ codeActionTests =
123123
cas <- map fromAction <$> getAllCodeActions doc
124124
liftIO $ "Disable \"unused-imports\" warnings" `elem` map (^. L.title) cas @? "Contains unused-imports code action"
125125
executeCodeAction $ head cas
126+
127+
, goldenWithPragmas "doesn't suggest disabling type errors" "DeferredTypeErrors" $ \doc -> do
128+
129+
_ <- waitForDiagnosticsFrom doc
130+
cas <- map fromAction <$> getAllCodeActions doc
131+
liftIO $ "Disable \"deferred-type-errors\" warnings" `notElem` map (^. L.title) cas @? "Doesn't contain deferred-type-errors code action"
132+
liftIO $ length cas == 0 @? "Expected no code actions, but got: " <> show cas
126133
]
127134

128135
completionTests :: TestTree
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module DeferredTypeErrors where
2+
3+
foo :: Int
4+
foo = ()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module DeferredTypeErrors where
2+
3+
foo :: Int
4+
foo = ()

0 commit comments

Comments
 (0)