From 075a7bad2ab4e8360badfa2d0ae25c4d8eaf61f6 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Tue, 27 Mar 2007 15:37:23 +0000 Subject: [PATCH] more improvements for #1119 When GHCi compiles its code framgents for setting buffering, it wants to refer to base:System.IO rather than whatever System.IO is on the search path, unfortunately there's no way to do this in source code, so to hack around it we set the search path to empty before compiling these expressions (not forgetting to flush the finder cache afterward). --- compiler/ghci/GhciMonad.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/compiler/ghci/GhciMonad.hs b/compiler/ghci/GhciMonad.hs index 63c2af7..eaea844 100644 --- a/compiler/ghci/GhciMonad.hs +++ b/compiler/ghci/GhciMonad.hs @@ -16,6 +16,7 @@ import Breakpoints import Outputable import Panic hiding (showException) import Util +import DynFlags import Numeric import Control.Exception as Exception @@ -205,8 +206,14 @@ flush_cmd = command_sequence [flush_buffer "stdout", flush_buffer "stderr"] initInterpBuffering :: GHC.Session -> IO () initInterpBuffering session - = do maybe_hval <- GHC.compileExpr session no_buf_cmd - + = do -- we don't want to be fooled by any modules lying around in the current + -- directory when we compile these code fragments, so set the import + -- path to be empty while we compile them. + dflags <- GHC.getSessionDynFlags session + GHC.setSessionDynFlags session dflags{importPaths=[]} + + maybe_hval <- GHC.compileExpr session no_buf_cmd + case maybe_hval of Just hval -> writeIORef turn_off_buffering (unsafeCoerce# hval :: IO ()) other -> panic "interactiveUI:setBuffering" @@ -216,6 +223,8 @@ initInterpBuffering session Just hval -> writeIORef flush_interp (unsafeCoerce# hval :: IO ()) _ -> panic "interactiveUI:flush" + GHC.setSessionDynFlags session dflags + GHC.workingDirectoryChanged session return () -- 1.7.10.4