diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2022-06-15 11:45:33 +0100 |
---|---|---|
committer | sheaf <sam.derbyshire@gmail.com> | 2022-10-18 16:15:49 +0200 |
commit | e1bbd36841e19812c7ed544b66256da82ce68fd5 (patch) | |
tree | 5e524caae7e938509097b95bf0069317ed58db91 /compiler/GHC.hs | |
parent | ba4bd4a48223bc9b215cfda138a5de9f99c87cdf (diff) | |
download | haskell-e1bbd36841e19812c7ed544b66256da82ce68fd5.tar.gz |
Allow configuration of error message printing
This MR implements the idea of #21731 that the printing of a diagnostic
method should be configurable at the printing time.
The interface of the `Diagnostic` class is modified from:
```
class Diagnostic a where
diagnosticMessage :: a -> DecoratedSDoc
diagnosticReason :: a -> DiagnosticReason
diagnosticHints :: a -> [GhcHint]
```
to
```
class Diagnostic a where
type DiagnosticOpts a
defaultDiagnosticOpts :: DiagnosticOpts a
diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc
diagnosticReason :: a -> DiagnosticReason
diagnosticHints :: a -> [GhcHint]
```
and so each `Diagnostic` can implement their own configuration record
which can then be supplied by a client in order to dictate how to print
out the error message.
At the moment this only allows us to implement #21722 nicely but in
future it is more natural to separate the configuration of how much
information we put into an error message and how much we decide to print
out of it.
Updates Haddock submodule
Diffstat (limited to 'compiler/GHC.hs')
-rw-r--r-- | compiler/GHC.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/GHC.hs b/compiler/GHC.hs index 1711e1c802..26f870a5bc 100644 --- a/compiler/GHC.hs +++ b/compiler/GHC.hs @@ -929,7 +929,8 @@ checkNewDynFlags logger dflags = do -- See Note [DynFlags consistency] let (dflags', warnings) = makeDynFlagsConsistent dflags let diag_opts = initDiagOpts dflags - liftIO $ handleFlagWarnings logger diag_opts (map (Warn WarningWithoutFlag) warnings) + print_config = initPrintConfig dflags + liftIO $ handleFlagWarnings logger print_config diag_opts (map (Warn WarningWithoutFlag) warnings) return dflags' checkNewInteractiveDynFlags :: MonadIO m => Logger -> DynFlags -> m DynFlags @@ -939,7 +940,8 @@ checkNewInteractiveDynFlags logger dflags0 = do if xopt LangExt.StaticPointers dflags0 then do let diag_opts = initDiagOpts dflags0 - liftIO $ printOrThrowDiagnostics logger diag_opts $ singleMessage + print_config = initPrintConfig dflags0 + liftIO $ printOrThrowDiagnostics logger print_config diag_opts $ singleMessage $ fmap GhcDriverMessage $ mkPlainMsgEnvelope diag_opts interactiveSrcSpan DriverStaticPointersNotSupported return $ xopt_unset dflags0 LangExt.StaticPointers |