diff options
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 |