From a136382590fccdedd791e44599fb54b648407e2b Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Sat, 18 Aug 2007 15:22:50 +0000 Subject: [PATCH] Fix trac #1565: :r DoesNotExist needs to remove any let-bound values --- compiler/main/GHC.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs index 506a839..bf276d5 100644 --- a/compiler/main/GHC.hs +++ b/compiler/main/GHC.hs @@ -273,7 +273,7 @@ import Control.Exception as Exception hiding (handle) import Data.IORef import System.IO import System.IO.Error ( try, isDoesNotExistError ) -import Prelude hiding (init) +import Prelude hiding (init, catch) -- ----------------------------------------------------------------------------- @@ -539,9 +539,16 @@ load s@(Session ref) how_much -- graph is still retained in the Session. We can tell which modules -- were successfully loaded by inspecting the Session's HPT. mb_graph <- depanal s [] False - case mb_graph of - Just mod_graph -> load2 s how_much mod_graph + case mb_graph of + Just mod_graph -> catchingFailure $ load2 s how_much mod_graph Nothing -> return Failed + where catchingFailure f = f `catch` \e -> do + hsc_env <- readIORef ref + -- trac #1565 / test ghci021: + -- let bindings may explode if we try to use them after + -- failing to reload + writeIORef ref $! hsc_env{ hsc_IC = emptyInteractiveContext } + throw e load2 s@(Session ref) how_much mod_graph = do guessOutputFile s -- 1.7.10.4