summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2023-05-03 12:27:26 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2023-05-05 10:33:18 +0100
commit1315c369203302fcba8f4f5966bf0d834b93b866 (patch)
tree6f019c19397c915bf76c836a16e5096f32b0f6cd
parent4d1d819a11944a81513245ca6dff21df2acb2924 (diff)
downloadhaskell-wip/23305.tar.gz
Don't return complete HscEnv from upsweepwip/23305
By returning a complete HscEnv from upsweep the logger (as introduced by withDeferredDiagnostics) was escaping the scope of withDeferredDiagnostics and hence we were losing error messages. This is reminiscent of #20981, which also talks about writing errors into messages after their scope has ended. See #23305 for details.
-rw-r--r--compiler/GHC/Driver/Make.hs11
-rw-r--r--testsuite/tests/ghci/prog018/prog018.stdout3
2 files changed, 8 insertions, 6 deletions
diff --git a/compiler/GHC/Driver/Make.hs b/compiler/GHC/Driver/Make.hs
index 7a42440e16..c9efc87f03 100644
--- a/compiler/GHC/Driver/Make.hs
+++ b/compiler/GHC/Driver/Make.hs
@@ -772,10 +772,10 @@ load' mhmi_cache how_much mHscMessage mod_graph = do
worker_limit <- liftIO $ mkWorkerLimit dflags
setSession $ hscUpdateHUG (unitEnv_map pruneHomeUnitEnv) hsc_env
- (upsweep_ok, hsc_env1) <- withDeferredDiagnostics $ do
+ (upsweep_ok, new_deps) <- withDeferredDiagnostics $ do
hsc_env <- getSession
liftIO $ upsweep worker_limit hsc_env mhmi_cache mHscMessage (toCache pruned_cache) build_plan
- setSession hsc_env1
+ modifySession (addDepsToHscEnv new_deps)
case upsweep_ok of
Failed -> loadFinish upsweep_ok
Succeeded -> do
@@ -1248,14 +1248,13 @@ upsweep
-> Maybe Messager
-> M.Map ModNodeKeyWithUid HomeModInfo
-> [BuildPlan]
- -> IO (SuccessFlag, HscEnv)
+ -> IO (SuccessFlag, [HomeModInfo])
upsweep n_jobs hsc_env hmi_cache mHscMessage old_hpt build_plan = do
(cycle, pipelines, collect_result) <- interpretBuildPlan (hsc_HUG hsc_env) hmi_cache old_hpt build_plan
runPipelines n_jobs hsc_env mHscMessage pipelines
res <- collect_result
let completed = [m | Just (Just m) <- res]
- let hsc_env' = addDepsToHscEnv completed hsc_env
-- Handle any cycle in the original compilation graph and return the result
-- of the upsweep.
@@ -1263,10 +1262,10 @@ upsweep n_jobs hsc_env hmi_cache mHscMessage old_hpt build_plan = do
Just mss -> do
let logger = hsc_logger hsc_env
liftIO $ fatalErrorMsg logger (cyclicModuleErr mss)
- return (Failed, hsc_env)
+ return (Failed, [])
Nothing -> do
let success_flag = successIf (all isJust res)
- return (success_flag, hsc_env')
+ return (success_flag, completed)
toCache :: [HomeModInfo] -> M.Map (ModNodeKeyWithUid) HomeModInfo
toCache hmis = M.fromList ([(miKey $ hm_iface hmi, hmi) | hmi <- hmis])
diff --git a/testsuite/tests/ghci/prog018/prog018.stdout b/testsuite/tests/ghci/prog018/prog018.stdout
index 1fff03d755..19a2049c2b 100644
--- a/testsuite/tests/ghci/prog018/prog018.stdout
+++ b/testsuite/tests/ghci/prog018/prog018.stdout
@@ -19,4 +19,7 @@ C.hs:6:7: error: [GHC-88464]
Variable not in scope: variableNotInScope :: ()
Failed, two modules loaded.
[3 of 3] Compiling C ( C.hs, interpreted )
+
+C.hs:6:7: error: [GHC-88464]
+ Variable not in scope: variableNotInScope :: ()
Failed, two modules loaded.