summaryrefslogtreecommitdiff
path: root/compiler/GHC/Driver/Main.hs
diff options
context:
space:
mode:
authorJakob Brünker <jakob.bruenker@gmail.com>2022-03-18 17:56:07 +0100
committerJakob Brünker <jakob.bruenker@gmail.com>2022-03-24 18:00:07 +0100
commitb05ffcbf6c46f053b5c707fee6579bee08449c77 (patch)
tree8eb57106869c745e13a4aa4de4a97d34436796f8 /compiler/GHC/Driver/Main.hs
parented04aed2b2d87d605c1cd13161bd3511e43c9452 (diff)
downloadhaskell-wip/T20803.tar.gz
Give parsing plugins access to errorswip/T20803
Previously, when the parser produced non-fatal errors (i.e. it produced errors but the 'PState' is 'POk'), compilation would be aborted before the 'parsedResultAction' of any plugin was invoked. This commit changes that, so that such that 'parsedResultAction' gets collections of warnings and errors as argument, and must return them after potentially modifying them. Closes #20803
Diffstat (limited to 'compiler/GHC/Driver/Main.hs')
-rw-r--r--compiler/GHC/Driver/Main.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/GHC/Driver/Main.hs b/compiler/GHC/Driver/Main.hs
index 62187d573f..d0fde311e4 100644
--- a/compiler/GHC/Driver/Main.hs
+++ b/compiler/GHC/Driver/Main.hs
@@ -443,8 +443,6 @@ hscParse' mod_summary
PFailed pst ->
handleWarningsThrowErrors (getPsMessages pst)
POk pst rdr_module -> do
- let (warns, errs) = getPsMessages pst
- logDiagnostics (GhcPsMessage <$> warns)
liftIO $ putDumpFileMaybe logger Opt_D_dump_parsed "Parser"
FormatHaskell (ppr rdr_module)
liftIO $ putDumpFileMaybe logger Opt_D_dump_parsed_ast "Parser AST"
@@ -453,7 +451,6 @@ hscParse' mod_summary
rdr_module)
liftIO $ putDumpFileMaybe logger Opt_D_source_stats "Source Statistics"
FormatText (ppSourceStats False rdr_module)
- when (not $ isEmptyMessages errs) $ throwErrors (GhcPsMessage <$> errs)
-- To get the list of extra source files, we take the list
-- that the parser gave us,
@@ -489,9 +486,15 @@ hscParse' mod_summary
-- apply parse transformation of plugins
let applyPluginAction p opts
- = parsedResultAction p opts mod_summary
+ = uncurry (parsedResultAction p opts mod_summary)
hsc_env <- getHscEnv
- withPlugins (hsc_plugins hsc_env) applyPluginAction res
+ (transformed, (warns, errs)) <-
+ withPlugins (hsc_plugins hsc_env) applyPluginAction (res, getPsMessages pst)
+
+ logDiagnostics (GhcPsMessage <$> warns)
+ unless (isEmptyMessages errs) $ throwErrors (GhcPsMessage <$> errs)
+
+ return transformed
checkBidirectionFormatChars :: PsLoc -> StringBuffer -> Maybe (NonEmpty (PsLoc, Char, String))
checkBidirectionFormatChars start_loc sb