summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-02-23 14:14:38 +0000
committerKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2021-02-27 15:30:30 +0100
commit1983f148b19cd2ca45b68d0931c334c189af9c31 (patch)
treeab977465715ec8ae9238ae055f767ca5ff991e4e
parent157fe938eabf6428fa9de42d57f8cfad08b38ddb (diff)
downloadhaskell-wip/tcgblenv-retain.tar.gz
Fix two places where TcGblEnv was retainedwip/tcgblenv-retain
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