diff options
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/GHCi/UI.hs | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index d48bf467f5..2f0dfcde8d 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -1954,23 +1954,26 @@ loadModule' files = do -- as a ToDo for now. hsc_env <- GHC.getSession - - -- Grab references to the currently loaded modules so that we can - -- see if they leak. let !dflags = hsc_dflags hsc_env - leak_indicators <- if gopt Opt_GhciLeakCheck dflags - then liftIO $ getLeakIndicators hsc_env - else return (panic "no leak indicators") - - -- unload first - _ <- GHC.abandonAll - clearAllTargets - GHC.setTargets targets - success <- doLoadAndCollectInfo False LoadAllTargets - when (gopt Opt_GhciLeakCheck dflags) $ - liftIO $ checkLeakIndicators dflags leak_indicators - return success + let load_module = do + -- unload first + _ <- GHC.abandonAll + clearAllTargets + + GHC.setTargets targets + doLoadAndCollectInfo False LoadAllTargets + + if gopt Opt_GhciLeakCheck dflags + then do + -- Grab references to the currently loaded modules so that we can see if + -- they leak. + leak_indicators <- liftIO $ getLeakIndicators hsc_env + success <- load_module + liftIO $ checkLeakIndicators dflags leak_indicators + return success + else + load_module -- | @:add@ command addModule :: GhciMonad m => [FilePath] -> m () |