summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser/Header.hs
diff options
context:
space:
mode:
authorAlfredo Di Napoli <alfredo@well-typed.com>2021-03-01 09:27:54 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-04-01 16:13:23 -0400
commit15b6c9f920d8f60ebfef4580ec7e8f063799a83a (patch)
tree7e40890412df649c043881b57d44e6a157f4108c /compiler/GHC/Parser/Header.hs
parentd44e42a26e54857cc6174f2bb7dc86cc41fcd249 (diff)
downloadhaskell-15b6c9f920d8f60ebfef4580ec7e8f063799a83a.tar.gz
Compute Severity of diagnostics at birth
This commit further expand on the design for #18516 by getting rid of the `defaultReasonSeverity` in favour of a function called `diagReasonSeverity` which correctly takes the `DynFlags` as input. The idea is to compute the `Severity` and the `DiagnosticReason` of each message "at birth", without doing any later re-classifications, which are potentially error prone, as the `DynFlags` might evolve during the course of the program. In preparation for a proper refactoring, now `pprWarning` from the Parser.Ppr module has been renamed to `mkParserWarn`, which now takes a `DynFlags` as input. We also get rid of the reclassification we were performing inside `printOrThrowWarnings`. Last but not least, this commit removes the need for reclassify inside GHC.Tc.Errors, and also simplifies the implementation of `maybeReportError`. Update Haddock submodule
Diffstat (limited to 'compiler/GHC/Parser/Header.hs')
-rw-r--r--compiler/GHC/Parser/Header.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/GHC/Parser/Header.hs b/compiler/GHC/Parser/Header.hs
index a80620eed4..c45cae45ca 100644
--- a/compiler/GHC/Parser/Header.hs
+++ b/compiler/GHC/Parser/Header.hs
@@ -48,6 +48,7 @@ import GHC.Utils.Misc
import GHC.Utils.Outputable as Outputable
import GHC.Utils.Panic
import GHC.Utils.Monad
+import GHC.Utils.Error
import GHC.Utils.Exception as Exception
import GHC.Data.StringBuffer
@@ -90,7 +91,7 @@ getImports popts implicit_prelude buf filename source_filename = do
-- don't log warnings: they'll be reported when we parse the file
-- for real. See #2500.
if not (isEmptyBag errs)
- then throwIO $ mkSrcErr (fmap pprError errs)
+ then throwIO $ mkSrcErr (fmap mkParserErr errs)
else
let hsmod = unLoc rdr_module
mb_mod = hsmodName hsmod
@@ -314,7 +315,7 @@ checkProcessArgsResult flags
= when (notNull flags) $
liftIO $ throwIO $ mkSrcErr $ listToBag $ map mkMsg flags
where mkMsg (L loc flag)
- = mkPlainMsgEnvelope ErrorWithoutFlag loc $
+ = mkPlainErrorMsgEnvelope loc $
(text "unknown flag in {-# OPTIONS_GHC #-} pragma:" <+>
text flag)
@@ -358,7 +359,7 @@ optionsErrorMsgs unhandled_flags flags_lines _filename
, L l f' <- flags_lines
, f == f' ]
mkMsg (L flagSpan flag) =
- mkPlainMsgEnvelope ErrorWithoutFlag flagSpan $
+ mkPlainErrorMsgEnvelope flagSpan $
text "unknown flag in {-# OPTIONS_GHC #-} pragma:" <+> text flag
optionsParseError :: String -> SrcSpan -> a -- #15053
@@ -371,4 +372,4 @@ optionsParseError str loc =
throwErr :: SrcSpan -> SDoc -> a -- #15053
throwErr loc doc =
- throw $ mkSrcErr $ unitBag $ mkPlainMsgEnvelope ErrorWithoutFlag loc doc
+ throw $ mkSrcErr $ unitBag $ mkPlainErrorMsgEnvelope loc doc