summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorAlfredo Di Napoli <alfredo@well-typed.com>2021-03-26 10:17:26 +0100
committerAlfredo Di Napoli <alfredo@well-typed.com>2021-03-29 07:58:00 +0200
commitc30af95189c5006ac5cd10839a8ea7e8098341d5 (patch)
tree8863e8d15ab33363147594dbab2d54cf7cb42a48 /ghc
parent9c9e40e59214b1e358c85852218f3a67e712a748 (diff)
downloadhaskell-c30af95189c5006ac5cd10839a8ea7e8098341d5.tar.gz
Add `MessageClass`, rework `Severity` and add `DiagnosticReason`.wip/adinapoli-message-class-new-design
Other than that: * Fix T16167,json,json2,T7478,T10637 tests to reflect the introduction of the `MessageClass` type * Remove `makeIntoWarning` * Remove `warningsToMessages` * Refactor GHC.Tc.Errors 1. Refactors GHC.Tc.Errors so that we use `DiagnosticReason` for "choices" (defer types errors, holes, etc); 2. We get rid of `reportWarning` and `reportError` in favour of a general `reportDiagnostic`. * Introduce `DiagnosticReason`, `Severity` is an enum: This big commit makes `Severity` a simple enumeration, and introduces the concept of `DiagnosticReason`, which classifies the /reason/ why we are emitting a particular diagnostic. It also adds a monomorphic `DiagnosticMessage` type which is used for generic messages. * The `Severity` is computed (for now) from the reason, statically. Later improvement will add a `diagReasonSeverity` function to compute the `Severity` taking `DynFlags` into account. * Rename `logWarnings` into `logDiagnostics` * Add note and expand description of the `mkHoleError` function
Diffstat (limited to 'ghc')
-rw-r--r--ghc/GHCi/UI.hs10
-rw-r--r--ghc/Main.hs2
2 files changed, 6 insertions, 6 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index a028f4e479..a97200c5c3 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -577,10 +577,10 @@ resetLastErrorLocations = do
ghciLogAction :: IORef [(FastString, Int)] -> LogAction -> LogAction
ghciLogAction lastErrLocations old_log_action
- dflags flag severity srcSpan msg = do
- old_log_action dflags flag severity srcSpan msg
- case severity of
- SevError -> case srcSpan of
+ dflags msg_class srcSpan msg = do
+ old_log_action dflags msg_class srcSpan msg
+ case msg_class of
+ MCDiagnostic SevError _reason -> case srcSpan of
RealSrcSpan rsp _ -> modifyIORef lastErrLocations
(++ [(srcLocFile (realSrcSpanStart rsp), srcLocLine (realSrcSpanStart rsp))])
_ -> return ()
@@ -3188,7 +3188,7 @@ showCmd str = do
, action "bindings" $ showBindings
, action "linker" $ do
msg <- liftIO $ Loader.showLoaderState (hscInterp hsc_env)
- putLogMsgM NoReason SevDump noSrcSpan msg
+ putLogMsgM MCDump noSrcSpan msg
, action "breaks" $ showBkptTable
, action "context" $ showContext
, action "packages" $ showUnits
diff --git a/ghc/Main.hs b/ghc/Main.hs
index 9da5469b8a..2873cba4ad 100644
--- a/ghc/Main.hs
+++ b/ghc/Main.hs
@@ -23,7 +23,7 @@ import GHC.Driver.CmdLine
import GHC.Driver.Env
import GHC.Driver.Errors
import GHC.Driver.Phases
-import GHC.Driver.Session hiding (WarnReason(..))
+import GHC.Driver.Session
import GHC.Driver.Ppr
import GHC.Driver.Pipeline ( oneShot, compileFile )
import GHC.Driver.MakeFile ( doMkDependHS )