... | ... | @@ -175,7 +175,28 @@ API design explanation/considerations: |
|
|
* Relating a reason with a severity requires the use of the `DynFlags`, because the `DynFlags` stores the presence/absence of the `-Wblah-blah` flags.
|
|
|
* Not just any `DynFlags` will do when converting a *reason* to a *severity*: we must use the `DynFlags` in action when the diagnostic was generated. This is important because, for example, `deriving` code might give rise to a warning that we wish to suppress, even with `-Werror` enabled. This is accomplished by locally changing the `DynFlags` while processing code generated by `deriving`. If we use the outer, top-level `DynFlags` to get a severity from a reason, we'll get this wrong. Conclusion: the severity must be chosen when the error message is first created or soon thereafter. (Current design: soon thereafter.)
|
|
|
* When we have informative datatypes describing errors (like `TcRnMessage`), each constructor will be associated with precisely one reason.
|
|
|
* Not all messages are diagnostics, but non-diagnostic error messages do not have associated reasons or flags.
|
|
|
* Not all messages are diagnostics, but non-diagnostic error messages do not have associated reasons or flags. Real-world example from GHC:
|
|
|
|
|
|
```hs
|
|
|
displayLintResults :: ...
|
|
|
displayLintResults logger dflags display_warnings pp_what pp_pgm (warns, errs)
|
|
|
| not (isEmptyBag errs)
|
|
|
= do { putLogMsg logger dflags Err.MCDump noSrcSpan
|
|
|
$ withPprStyle defaultDumpStyle
|
|
|
(vcat [ lint_banner "errors" pp_what, Err.pprMessageBag errs
|
|
|
, text "*** Offending Program ***"
|
|
|
, pp_pgm
|
|
|
, text "*** End of Offense ***" ])
|
|
|
; Err.ghcExit logger dflags 1 }
|
|
|
|
|
|
{-
|
|
|
This is just an informational message, it doesn't have a `DiagnosticReason` or a flag: it's
|
|
|
just GHC telling us something as a statement, so it's logged with `MCDump`. Previously to this
|
|
|
design things like `Dump`,`Info`,`Fatal`, etc were a `Severity`, which meant we could construct
|
|
|
a GHC warning or error with `Severity = Dump` for example, which would have been nonsense.
|
|
|
-}
|
|
|
```
|
|
|
|
|
|
* Messages sometimes have bullet points in them.
|
|
|
|
|
|
A lesser (but non-negligible) concern:
|
... | ... | |