diff options
author | Alfredo Di Napoli <alfredo@well-typed.com> | 2021-03-01 09:27:54 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-04-01 16:13:23 -0400 |
commit | 15b6c9f920d8f60ebfef4580ec7e8f063799a83a (patch) | |
tree | 7e40890412df649c043881b57d44e6a157f4108c /utils | |
parent | d44e42a26e54857cc6174f2bb7dc86cc41fcd249 (diff) | |
download | haskell-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 'utils')
-rw-r--r-- | utils/check-exact/Parsers.hs | 8 | ||||
-rw-r--r-- | utils/check-exact/Preprocess.hs | 2 | ||||
m--------- | utils/haddock | 0 |
3 files changed, 5 insertions, 5 deletions
diff --git a/utils/check-exact/Parsers.hs b/utils/check-exact/Parsers.hs index eccf3f2612..f1437869ee 100644 --- a/utils/check-exact/Parsers.hs +++ b/utils/check-exact/Parsers.hs @@ -87,7 +87,7 @@ parseWith :: GHC.DynFlags -> ParseResult w parseWith dflags fileName parser s = case runParser parser dflags fileName s of - GHC.PFailed pst -> Left (fmap GHC.pprError $ GHC.getErrorMessages pst) + GHC.PFailed pst -> Left (fmap GHC.mkParserErr $ GHC.getErrorMessages pst) GHC.POk _ pmod -> Right pmod @@ -101,7 +101,7 @@ parseWithECP dflags fileName parser s = -- case runParser ff dflags fileName s of -- case runParser (parser >>= \p -> GHC.runECP_P p) dflags fileName s of case runParser (parser >>= \p -> GHC.runPV $ GHC.unECP p) dflags fileName s of - GHC.PFailed pst -> Left (fmap GHC.pprError $ GHC.getErrorMessages pst) + GHC.PFailed pst -> Left (fmap GHC.mkParserErr $ GHC.getErrorMessages pst) GHC.POk _ pmod -> Right pmod -- --------------------------------------------------------------------- @@ -192,7 +192,7 @@ parseModuleFromStringInternal :: Parser GHC.ParsedSource parseModuleFromStringInternal dflags fileName str = let (str1, lp) = stripLinePragmas str res = case runParser GHC.parseModule dflags fileName str1 of - GHC.PFailed pst -> Left (fmap GHC.pprError $ GHC.getErrorMessages pst) + GHC.PFailed pst -> Left (fmap GHC.mkParserErr $ GHC.getErrorMessages pst) GHC.POk _ pmod -> Right (lp, dflags, pmod) in postParseTransform res @@ -263,7 +263,7 @@ parseModuleEpAnnsWithCppInternal cppOptions dflags file = do return (contents1,lp,dflags) return $ case parseFile dflags' file fileContents of - GHC.PFailed pst -> Left (fmap GHC.pprError $ GHC.getErrorMessages pst) + GHC.PFailed pst -> Left (fmap GHC.mkParserErr $ GHC.getErrorMessages pst) GHC.POk _ pmod -> Right $ (injectedComments, dflags', pmod) diff --git a/utils/check-exact/Preprocess.hs b/utils/check-exact/Preprocess.hs index 761029adb2..904e76938e 100644 --- a/utils/check-exact/Preprocess.hs +++ b/utils/check-exact/Preprocess.hs @@ -277,7 +277,7 @@ parseError pst = do let -- (warns,errs) = GHC.getMessages pst dflags -- throw $ GHC.mkSrcErr (GHC.unitBag $ GHC.mkPlainErrMsg dflags sspan err) - GHC.throwErrors (fmap GHC.pprError (GHC.getErrorMessages pst)) + GHC.throwErrors (fmap GHC.mkParserErr (GHC.getErrorMessages pst)) -- --------------------------------------------------------------------- diff --git a/utils/haddock b/utils/haddock -Subproject c623c7d2df417caac4b72b747ef5262d86ee776 +Subproject eebc74dc08987fdd9b1c289be38207af9b0334c |