diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-08-19 20:16:21 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-10-01 18:36:11 -0400 |
commit | a5aaceecaa04ce7ea5bade6eb96c0d129109c15a (patch) | |
tree | 80035738c384ef5e4bf8a4f943bbac5808c8c921 /testsuite/tests | |
parent | dca1cb22cab4fa7f5937e9ffdc0ee32313dbd01c (diff) | |
download | haskell-a5aaceecaa04ce7ea5bade6eb96c0d129109c15a.tar.gz |
Use ADTs for parser errors/warnings
Haskell and Cmm parsers/lexers now report errors and warnings using ADTs
defined in GHC.Parser.Errors. They can be printed using functions in
GHC.Parser.Errors.Ppr.
Some of the errors provide hints with a separate ADT (e.g. to suggest to
turn on some extension). For now, however, hints are not consistent
across all messages. For example some errors contain the hints in the
main message. I didn't want to change any message with this patch. I
expect these changes to be discussed and implemented later.
Surprisingly, this patch enhances performance. On CI
(x86_64/deb9/hadrian, ghc/alloc):
parsing001 -11.5%
T13719 -2.7%
MultiLayerModules -3.5%
Naperian -3.1%
Bump haddock submodule
Metric Decrease:
MultiLayerModules
Naperian
T13719
parsing001
Diffstat (limited to 'testsuite/tests')
4 files changed, 7 insertions, 3 deletions
diff --git a/testsuite/tests/parser/should_fail/T8501a.stderr b/testsuite/tests/parser/should_fail/T8501a.stderr index d85dfc29f9..44431fca77 100644 --- a/testsuite/tests/parser/should_fail/T8501a.stderr +++ b/testsuite/tests/parser/should_fail/T8501a.stderr @@ -1,4 +1,5 @@ T8501a.hs:5:3: error: Parse error in pattern: rec + Possibly caused by a missing 'do'? Perhaps you intended to use RecursiveDo diff --git a/testsuite/tests/parser/should_fail/readFail018.stderr b/testsuite/tests/parser/should_fail/readFail018.stderr index d07aa622c0..1391d5736c 100644 --- a/testsuite/tests/parser/should_fail/readFail018.stderr +++ b/testsuite/tests/parser/should_fail/readFail018.stderr @@ -1,2 +1,2 @@ -readFail018.hs:3:1: unterminated `{-' +readFail018.hs:3:1: error: unterminated `{-' at end of input diff --git a/testsuite/tests/parser/should_run/CountParserDeps.hs b/testsuite/tests/parser/should_run/CountParserDeps.hs index ae344aaf49..5c7cb0eef3 100644 --- a/testsuite/tests/parser/should_run/CountParserDeps.hs +++ b/testsuite/tests/parser/should_run/CountParserDeps.hs @@ -28,7 +28,7 @@ main = do [libdir] <- getArgs modules <- parserDeps libdir let num = sizeUniqSet modules - max_num = 201 + max_num = 203 min_num = max_num - 10 -- so that we don't forget to change the number -- when the number of dependencies decreases -- putStrLn $ "Found " ++ show num ++ " parser module dependencies" diff --git a/testsuite/tests/regalloc/regalloc_unit_tests.hs b/testsuite/tests/regalloc/regalloc_unit_tests.hs index d8176cd644..c6902d48be 100644 --- a/testsuite/tests/regalloc/regalloc_unit_tests.hs +++ b/testsuite/tests/regalloc/regalloc_unit_tests.hs @@ -33,6 +33,7 @@ import GHC.Cmm.Pipeline import GHC.Cmm.Parser import GHC.Cmm.Info import GHC.Cmm +import GHC.Parser.Errors.Ppr import GHC.Unit.Module import GHC.Cmm.DebugBlock import GHC @@ -109,7 +110,9 @@ compileCmmForRegAllocStats dflags' cmmFile ncgImplF us = do hscEnv <- newHscEnv dflags -- parse the cmm file and output any warnings or errors - ((warningMsgs, errorMsgs), parsedCmm) <- parseCmmFile dflags cmmFile + (warnings, errors, parsedCmm) <- parseCmmFile dflags cmmFile + let warningMsgs = fmap pprWarning warnings + errorMsgs = fmap pprError errors -- print parser errors or warnings mapM_ (printBagOfErrors dflags) [warningMsgs, errorMsgs] |