From 4f785d7f8a82c29f493851cab9e2633d80425e3c Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Thu, 14 Aug 2014 14:13:09 +0900 Subject: [PATCH] Set Opt_DeferTypeErrors to rescure type errors. (#310) Type errors are turned to warnings. We force to turn them to the errors again. --- Language/Haskell/GhcMod/Check.hs | 2 +- Language/Haskell/GhcMod/Logger.hs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Language/Haskell/GhcMod/Check.hs b/Language/Haskell/GhcMod/Check.hs index 6d30f55..ea2e28a 100644 --- a/Language/Haskell/GhcMod/Check.hs +++ b/Language/Haskell/GhcMod/Check.hs @@ -37,7 +37,7 @@ check :: IOish m => [FilePath] -- ^ The target files. -> GhcModT m (Either String String) check fileNames = overrideGhcUserOptions $ \ghcOpts -> - withLogger (setAllWaringFlags . setNoMaxRelevantBindings) $ do + withLogger (setAllWaringFlags . setNoMaxRelevantBindings . Gap.setWarnTypedHoles . Gap.setDeferTypeErrors) $ do _ <- G.setSessionDynFlags =<< addCmdOpts ghcOpts =<< G.getSessionDynFlags setTargetFiles fileNames diff --git a/Language/Haskell/GhcMod/Logger.hs b/Language/Haskell/GhcMod/Logger.hs index 0263561..d3b712b 100644 --- a/Language/Haskell/GhcMod/Logger.hs +++ b/Language/Haskell/GhcMod/Logger.hs @@ -105,7 +105,13 @@ ppMsg spn sev dflag style msg = prefix ++ cts (line,col,_,_) <- Gap.getSrcSpan spn file <- normalise <$> Gap.getSrcFile spn let severityCaption = Gap.showSeverityCaption sev - return $ file ++ ":" ++ show line ++ ":" ++ show col ++ ":" ++ severityCaption + pref0 + | typeWarning `isPrefixOf` cts = file ++ ":" ++ show line ++ ":" ++ show col ++ ":" + | otherwise = file ++ ":" ++ show line ++ ":" ++ show col ++ ":" ++ severityCaption + return pref0 + -- DeferTypeErrors turns a type error to a warning. + -- So, let's turns it the error again. + typeWarning = "Couldn't match expected type" checkErrorPrefix :: String checkErrorPrefix = "Dummy:0:0:Error:"