summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-10-08 09:29:21 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-12 19:17:15 -0400
commit0c5d9ca8aa1e5574667e7da704a1ea24eb02cece (patch)
tree98c8941410644a6236494da0afbad52dd82046f0 /compiler/GHC/Tc
parentaf5ed1563a27ff1a4fabd8e20d1dcfbb5651bf5e (diff)
downloadhaskell-0c5d9ca8aa1e5574667e7da704a1ea24eb02cece.tar.gz
Be more careful about retaining KnotVars
It is quite easy to end up accidently retaining a KnotVars, which contains pointers to a stale TypeEnv because they are placed in the HscEnv. One place in particular we have to be careful is when loading a module into the EPS in `--make` mode, we have to remove the reference to KnotVars as otherwise the interface loading thunks will forever retain reference to the KnotVars which are live at the time the interface was loaded. These changes do not go as far as to enforce the invariant described in Note [KnotVar invariants] * At the end of upsweep, there should be no live KnotVars but at least improve the situation. This is left for future work (#20491)
Diffstat (limited to 'compiler/GHC/Tc')
-rw-r--r--compiler/GHC/Tc/Types.hs2
-rw-r--r--compiler/GHC/Tc/Utils/Monad.hs2
2 files changed, 2 insertions, 2 deletions
diff --git a/compiler/GHC/Tc/Types.hs b/compiler/GHC/Tc/Types.hs
index d3c4b44211..0ae52c6db3 100644
--- a/compiler/GHC/Tc/Types.hs
+++ b/compiler/GHC/Tc/Types.hs
@@ -317,7 +317,7 @@ data IfGblEnv
-- We need the module name so we can test when it's appropriate
-- to look in this env.
-- See Note [Tying the knot] in GHC.IfaceToCore
- if_rec_types :: !(KnotVars (IfG TypeEnv))
+ if_rec_types :: (KnotVars (IfG TypeEnv))
-- Allows a read effect, so it can be in a mutable
-- variable; c.f. handling the external package type env
-- Nothing => interactive stuff, no loops possible
diff --git a/compiler/GHC/Tc/Utils/Monad.hs b/compiler/GHC/Tc/Utils/Monad.hs
index 6b876d3121..1c80acdf9b 100644
--- a/compiler/GHC/Tc/Utils/Monad.hs
+++ b/compiler/GHC/Tc/Utils/Monad.hs
@@ -2087,7 +2087,7 @@ initIfaceLoad hsc_env do_this
if_doc = text "initIfaceLoad",
if_rec_types = emptyKnotVars
}
- initTcRnIf 'i' hsc_env gbl_env () do_this
+ initTcRnIf 'i' (hsc_env { hsc_type_env_vars = emptyKnotVars }) gbl_env () do_this
-- | This is used when we are doing to call 'typecheckModule' on an 'ModIface',
-- if it's part of a loop with some other modules then we need to use their