summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-02-23 14:14:38 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-28 05:39:41 -0500
commit035d983dfa217bf8784b86e78d6024a3ca1a3f4f (patch)
tree7fb0ee9a8a3cf987aca99cf216d94609221aee58
parent856929a5fa93e9fb13bd9efcb9049054fb1bde72 (diff)
downloadhaskell-035d983dfa217bf8784b86e78d6024a3ca1a3f4f.tar.gz
Fix two places where TcGblEnv was retained
Found with ghc-debug on the ManyConstructors test
-rw-r--r--compiler/GHC/Tc/Module.hs7
-rw-r--r--compiler/GHC/Tc/TyCl.hs4
2 files changed, 7 insertions, 4 deletions
diff --git a/compiler/GHC/Tc/Module.hs b/compiler/GHC/Tc/Module.hs
index dfc867c80a..08f7d0f4b1 100644
--- a/compiler/GHC/Tc/Module.hs
+++ b/compiler/GHC/Tc/Module.hs
@@ -491,9 +491,10 @@ tcRnSrcDecls explicit_mod_hdr decls export_ies
; (bind_env_mf, ev_binds_mf, binds_mf, fords_mf, imp_specs_mf, rules_mf)
<- zonkTcGblEnv emptyBag tcg_env_mf
-
- ; let { final_type_env = plusTypeEnv (tcg_type_env tcg_env)
- (plusTypeEnv bind_env_mf bind_env)
+ -- Force this or we retain an old reference to the previous
+ -- tcg_env
+ ; let { !final_type_env = plusTypeEnv (tcg_type_env tcg_env)
+ (plusTypeEnv bind_env_mf bind_env)
; tcg_env' = tcg_env_mf
{ tcg_binds = binds' `unionBags` binds_mf,
tcg_ev_binds = ev_binds' `unionBags` ev_binds_mf ,
diff --git a/compiler/GHC/Tc/TyCl.hs b/compiler/GHC/Tc/TyCl.hs
index 6f7a7c548c..45d38fd87d 100644
--- a/compiler/GHC/Tc/TyCl.hs
+++ b/compiler/GHC/Tc/TyCl.hs
@@ -239,7 +239,9 @@ tcTyClDecls tyclds kisig_env role_annots
-- loops yet and could fall into a black hole.
; fixM $ \ ~(rec_tyclss, _) -> do
{ tcg_env <- getGblEnv
- ; let roles = inferRoles (tcg_src tcg_env) role_annots rec_tyclss
+ -- Forced so we don't retain a reference to the TcGblEnv
+ ; let !src = tcg_src tcg_env
+ roles = inferRoles src role_annots rec_tyclss
-- Populate environment with knot-tied ATyCon for TyCons
-- NB: if the decls mention any ill-staged data cons