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 /compiler/GHC/Driver/Make.hs | |
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 'compiler/GHC/Driver/Make.hs')
-rw-r--r-- | compiler/GHC/Driver/Make.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/GHC/Driver/Make.hs b/compiler/GHC/Driver/Make.hs index de1746c815..a40efb74aa 100644 --- a/compiler/GHC/Driver/Make.hs +++ b/compiler/GHC/Driver/Make.hs @@ -45,6 +45,7 @@ import GHC.Utils.Error import GHC.Driver.Finder import GHC.Driver.Monad import GHC.Parser.Header +import GHC.Parser.Errors.Ppr import GHC.Driver.Types import GHC.Unit import GHC.Unit.State @@ -94,6 +95,7 @@ import Data.Foldable (toList) import Data.Maybe import Data.Ord ( comparing ) import Data.Time +import Data.Bifunctor (first) import System.Directory import System.FilePath import System.IO ( fixIO ) @@ -2669,7 +2671,9 @@ getPreprocessedImports hsc_env src_fn mb_phase maybe_buf = do <- ExceptT $ preprocess hsc_env src_fn (fst <$> maybe_buf) mb_phase pi_hspp_buf <- liftIO $ hGetStringBuffer pi_hspp_fn (pi_srcimps, pi_theimps, L pi_mod_name_loc pi_mod_name) - <- ExceptT $ getImports pi_local_dflags pi_hspp_buf pi_hspp_fn src_fn + <- ExceptT $ do + mimps <- getImports pi_local_dflags pi_hspp_buf pi_hspp_fn src_fn + return (first (fmap pprError) mimps) return PreprocessedImports {..} |