diff options
author | Roland Senn <rsx@bluewin.ch> | 2021-01-01 14:01:41 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-01-07 00:12:09 -0500 |
commit | 1de2050edd8a2647e89a9269278a79b61892b59e (patch) | |
tree | 2c902e80f7b030d42ddc38770b878a5db1315e48 /ghc | |
parent | 06982b6cc886d65aa325475ddfb4ad38c69b2d96 (diff) | |
download | haskell-1de2050edd8a2647e89a9269278a79b61892b59e.tar.gz |
GHCi: Fill field `DynFlags.dumpPrefix`. (Fixes #17500)
For interactive evaluations set the field `DynFlags.dumpPrefix` to the
GHCi internal module name. The GHCi module name for an interactive
evaluation is something like `Ghci9`.
To avoid user confusion, don't dump any data for GHCi internal evaluations.
Extend the comment for `DynFlags.dumpPrefix` and fix a little typo in a
comment about the GHCi internal module names.
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/GHCi/UI.hs | 13 | ||||
-rw-r--r-- | ghc/GHCi/UI/Monad.hs | 7 |
2 files changed, 18 insertions, 2 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index 4a1b91a9fc..5beca7882d 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -458,7 +458,7 @@ interactiveUI config srcs maybe_exprs = do _ <- liftIO $ newStablePtr stderr -- Initialise buffering for the *interpreted* I/O system - (nobuffering, flush) <- initInterpBuffering + (nobuffering, flush) <- runInternal initInterpBuffering -- The initial set of DynFlags used for interactive evaluation is the same -- as the global DynFlags, plus -XExtendedDefaultRules and @@ -1215,6 +1215,10 @@ runStmt input step = do -- and should therefore not be used here. | otherwise -> do hsc_env <- GHC.getSession + let !ic = hsc_IC hsc_env -- Bang-pattern to avoid space leaks + setDumpFilePrefix ic + -- `-ddump-to-file` must work for normal GHCi compilations / + -- evaluations. (#17500) decls <- liftIO (hscParseDeclsWithLocation hsc_env source line input) run_decls decls where @@ -1270,6 +1274,13 @@ runStmt input step = do l = L loc in l (LetStmt noExtField (l (HsValBinds noExtField (ValBinds noExtField (unitBag (l bind)) [])))) + setDumpFilePrefix :: GHC.GhcMonad m => InteractiveContext -> m () -- #17500 + setDumpFilePrefix ic = do + dflags <- GHC.getInteractiveDynFlags + GHC.setInteractiveDynFlags dflags { dumpPrefix = Just (modStr ++ ".") } + where + modStr = moduleNameString $ moduleName $ icInteractiveModule $ ic + -- | Clean up the GHCi environment after a statement has run afterRunStmt :: GhciMonad m => (SrcSpan -> Bool) -> GHC.ExecResult -> m GHC.ExecResult diff --git a/ghc/GHCi/UI/Monad.hs b/ghc/GHCi/UI/Monad.hs index 87de1a83cb..b371a9b8b4 100644 --- a/ghc/GHCi/UI/Monad.hs +++ b/ghc/GHCi/UI/Monad.hs @@ -31,6 +31,7 @@ module GHCi.UI.Monad ( initInterpBuffering, turnOffBuffering, turnOffBuffering_, flushInterpBuffers, + runInternal, mkEvalWrapper ) where @@ -74,6 +75,7 @@ import Control.Monad.Trans.Reader import Control.Monad.IO.Class import Data.Map.Strict (Map) import qualified Data.IntMap.Strict as IntMap +import qualified GHC.Data.EnumSet as EnumSet import qualified GHC.LanguageExtensions as LangExt ----------------------------------------------------------------------------- @@ -519,7 +521,10 @@ runInternal = -- Running GHCi's internal expression is incompatible with -XSafe. -- We temporarily disable any Safe Haskell settings while running -- GHCi internal expressions. (see #12509) - safeHaskell = Sf_None + safeHaskell = Sf_None, + -- Disable dumping of any data during evaluation of GHCi's internal + -- expressions. (#17500) + dumpFlags = EnumSet.empty } -- RebindableSyntax can wreak havoc with GHCi in several ways -- (see #13385 and #14342 for examples), so we temporarily |