summaryrefslogtreecommitdiff
path: root/compiler/GHC/Driver/Pipeline.hs
diff options
context:
space:
mode:
authorAlfredo Di Napoli <alfredo@well-typed.com>2021-06-01 09:57:09 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-06-04 12:43:41 -0400
commitf1b748b491dc49cfbe698cd790610ca21ae21ee7 (patch)
treed6ffa50d52e96217c1893a89adc840cbb0a5c5fa /compiler/GHC/Driver/Pipeline.hs
parent44d131af861e58b17f52c89da77a7ceeeba392c0 (diff)
downloadhaskell-f1b748b491dc49cfbe698cd790610ca21ae21ee7.tar.gz
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.
Diffstat (limited to 'compiler/GHC/Driver/Pipeline.hs')
-rw-r--r--compiler/GHC/Driver/Pipeline.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/GHC/Driver/Pipeline.hs b/compiler/GHC/Driver/Pipeline.hs
index 44ae426e2d..205c767aed 100644
--- a/compiler/GHC/Driver/Pipeline.hs
+++ b/compiler/GHC/Driver/Pipeline.hs
@@ -166,8 +166,12 @@ preprocess hsc_env input_fn mb_input_buf mb_phase =
(vcat $ pprMsgEnvelopeBagWithLoc (getMessages msgs))
Just msgs' -> msgs'
- to_driver_message (GhcDriverMessage msg) = Just msg
- to_driver_message _other = Nothing
+ to_driver_message = \case
+ GhcDriverMessage msg
+ -> Just msg
+ GhcPsMessage (PsHeaderMessage msg)
+ -> Just (DriverPsHeaderMessage (PsHeaderMessage msg))
+ _ -> Nothing
-- ---------------------------------------------------------------------------