X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypes%2FType.lhs;h=4be386c1edbddd55d650a6b3b50798898100ff7b;hb=a385f0af5ea320a18d580f6a36c59c55b3516efd;hp=df9e3c7218730eec854b89575f2b778af27a0bcf;hpb=e314b86f6290e5440a46cd5cc29f7878cb78c6fb;p=ghc-hetmet.git diff --git a/compiler/types/Type.lhs b/compiler/types/Type.lhs index df9e3c7..4be386c 100644 --- a/compiler/types/Type.lhs +++ b/compiler/types/Type.lhs @@ -1258,6 +1258,19 @@ extendTvSubstList (TvSubst in_scope env) tvs tys -- the types given; but it's just a thunk so with a bit of luck -- it'll never be evaluated +-- Note [Generating the in-scope set for a substitution] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- If we want to substitute [a -> ty1, b -> ty2] I used to +-- think it was enough to generate an in-scope set that includes +-- fv(ty1,ty2). But that's not enough; we really should also take the +-- free vars of the type we are substituting into! Example: +-- (forall b. (a,b,x)) [a -> List b] +-- Then if we use the in-scope set {b}, there is a danger we will rename +-- the forall'd variable to 'x' by mistake, getting this: +-- (forall x. (List b, x, x) +-- Urk! This means looking at all the calls to mkOpenTvSubst.... + + mkOpenTvSubst :: TvSubstEnv -> TvSubst mkOpenTvSubst env = TvSubst (mkInScopeSet (tyVarsOfTypes (varEnvElts env))) env @@ -1310,9 +1323,9 @@ zip_ty_env tvs tys env = pprTrace "Var/Type length mismatch: " (ppr instance Outputable TvSubst where ppr (TvSubst ins env) - = brackets $ sep[ ptext SLIT("TvSubst"), - nest 2 (ptext SLIT("In scope:") <+> ppr ins), - nest 2 (ptext SLIT("Env:") <+> ppr env) ] + = brackets $ sep[ ptext (sLit "TvSubst"), + nest 2 (ptext (sLit "In scope:") <+> ppr ins), + nest 2 (ptext (sLit "Env:") <+> ppr env) ] \end{code} %************************************************************************