Add PsHeaderMessage diagnostic (fixes #19923)
This commit replaces the PsUnknownMessage
diagnostics over at GHC.Parser.Header
with a new PsHeaderMessage
type (part of the more general PsMessage
), so that we can throw parser header's errors which can be correctly caught by GHC.Driver.Pipeline.preprocess
and rewrapped (correctly) as Driver messages (using the DriverPsHeaderMessage
).
This gets rid of the nasty compiler crash as part of #19923 (closed).
In order to expedite the fix, I used an UnknownHint
instead of a proper type constructor for the hint we emit as part of PsErrUnsupportedExt
. I have done that mostly because it would be nice to do this properly in a different patch: currently supportedLanguagesAndExtensions
gives us back a [String]
, but it would be nice if it could gives us back something more structured. However, from a cursory look, that doesn't look like a quick thing to do and might require some refactoring and/or some upfront thinking, which I didn't want to make as part of this hotfix.
I have also added 3 new tests to catch this regression in the future.