diff options
author | simonpj@microsoft.com <unknown> | 2006-11-06 15:59:01 +0000 |
---|---|---|
committer | simonpj@microsoft.com <unknown> | 2006-11-06 15:59:01 +0000 |
commit | 94b170a053c161d1e0cc4418b37a6a4807872a5f (patch) | |
tree | 503c35e17451af58b27957469996aae81174ebd7 /compiler/simplCore/SimplEnv.lhs | |
parent | e513c1cc1de895fed5796d16cb67525f4b581b2a (diff) | |
download | haskell-94b170a053c161d1e0cc4418b37a6a4807872a5f.tar.gz |
Tidy up substitutions
The new simplifer stuff exposed the fact that the invariants on the
TvSubstEnv and IdSubstEnv were insufficiently explicit. (Resulted in
a bug found by Sam Brosnon.)
This patch fixes the bug, and tries to document the invariants pretty
thoroughly. See
Note [Extending the TvSubst] in Type
Note [Extenting the Subst] in CoreSubst
(Most of the new lines are comments.)
Diffstat (limited to 'compiler/simplCore/SimplEnv.lhs')
-rw-r--r-- | compiler/simplCore/SimplEnv.lhs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/simplCore/SimplEnv.lhs b/compiler/simplCore/SimplEnv.lhs index f9e048430b..765fd004d7 100644 --- a/compiler/simplCore/SimplEnv.lhs +++ b/compiler/simplCore/SimplEnv.lhs @@ -130,6 +130,7 @@ data SimplEnv } type SimplIdSubst = IdEnv SimplSR -- IdId |--> OutExpr + -- See Note [Extending the Subst] in CoreSubst data SimplSR = DoneEx OutExpr -- Completed term @@ -137,6 +138,7 @@ data SimplSR | ContEx TvSubstEnv -- A suspended substitution SimplIdSubst InExpr + instance Outputable SimplSR where ppr (DoneEx e) = ptext SLIT("DoneEx") <+> ppr e ppr (DoneId v) = ptext SLIT("DoneId") <+> ppr v @@ -531,6 +533,8 @@ substIdBndr :: SimplEnv -> Id -- Substitition and Id to transform -- * The substitution extended with a DoneId if unique changed -- In this case, the var in the DoneId is the same as the -- var returned +-- +-- Exactly like CoreSubst.substIdBndr, except that the type of id_subst differs substIdBndr env@(SimplEnv { seInScope = in_scope, seIdSubst = id_subst}) old_id @@ -549,6 +553,7 @@ substIdBndr env@(SimplEnv { seInScope = in_scope, seIdSubst = id_subst}) -- Extend the substitution if the unique has changed -- See the notes with substTyVarBndr for the delSubstEnv + -- Also see Note [Extending the Subst] in CoreSubst new_subst | new_id /= old_id = extendVarEnv id_subst old_id (DoneId new_id) | otherwise |