on master help sign in
Merge pull request #59 from hsenag/unqualified-warnings
d669f53Moritz Kiefer
src/Development/IDE/GHC/Warnings.hs+3−2
@@ -29,8 +29,9 @@ withWarnings :: GhcMonad m => T.Text -> ((ModSummary -> ModSummary) -> m a) -> m
29withWarnings diagSource action = do
29withWarnings diagSource action = do
30 warnings <- liftIO $ newVar []
30 warnings <- liftIO $ newVar []
31 oldFlags <- getDynFlags
31 oldFlags <- getDynFlags
32+ let newAction :: DynFlags -> WarnReason -> Severity -> SrcSpan -> PprStyle -> SDoc -> IO ()
32− let newAction dynFlags _ _ loc _ msg = do
33+ newAction dynFlags _ _ loc style msg = do
33− let d = diagFromErrMsg diagSource dynFlags $ mkPlainWarnMsg dynFlags loc msg
34+ let d = diagFromErrMsg diagSource dynFlags $ mkWarnMsg dynFlags loc (queryQual style) msg
34 modifyVar_ warnings $ return . (d:)
35 modifyVar_ warnings $ return . (d:)
35 setLogAction newAction
36 setLogAction newAction
36 res <- action $ \x -> x{ms_hspp_opts = (ms_hspp_opts x){log_action = newAction}}
37 res <- action $ \x -> x{ms_hspp_opts = (ms_hspp_opts x){log_action = newAction}}
test/exe/Main.hs+18
@@ -206,6 +206,24 @@ diagnosticTests = testGroup "diagnostics"
206 ]
206 ]
207 )
207 )
208 ]
208 ]
209+ , testSession "unqualified warnings" $ do
210+ let fooContent = T.unlines
211+ [ "{-# OPTIONS_GHC -Wredundant-constraints #-}"
212+ , "module Foo where"
213+ , "foo :: Ord a => a -> Int"
214+ , "foo a = 1"
215+ ]
216+ _ <- openDoc' "Foo.hs" "haskell" fooContent
217+ expectDiagnostics
218+ [ ( "Foo.hs"
219+ -- The test is to make sure that warnings contain unqualified names
220+ -- where appropriate. The warning should use an unqualified name 'Ord', not
221+ -- sometihng like 'GHC.Classes.Ord'. The choice of redundant-constraints to
222+ -- test this is fairly arbitrary.
223+ , [(DsWarning, (2, 0), "Redundant constraint: Ord a")
224+ ]
225+ )
226+ ]
209 ]
227 ]
210
228
211codeActionTests :: TestTree
229codeActionTests :: TestTree