[commit: ghc] master: Zonk the free tvs of a RULE lhs to TyVars (f8c8de8)
git at git.haskell.org
git at git.haskell.org
Tue Nov 29 14:06:17 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/f8c8de8ebf73cd77faa0249d92f280e33a8d2624/ghc
>---------------------------------------------------------------
commit f8c8de8ebf73cd77faa0249d92f280e33a8d2624
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Tue Nov 29 14:03:46 2016 +0000
Zonk the free tvs of a RULE lhs to TyVars
Previously we were making them into skolem TcTyVars,
which is wrong for the output of the type checker, which
no TcTyVars should surive.
See Note [Zonking the LHS of a RULE] in TcHsSyn
This was flushed out by the new IfaceTcTyVar thing;
I found some more TcTyVars that were being serialised into
an interface file, which is wrong wrong wrong.
>---------------------------------------------------------------
f8c8de8ebf73cd77faa0249d92f280e33a8d2624
compiler/deSugar/DsBinds.hs | 2 +-
compiler/typecheck/TcHsSyn.hs | 20 ++++++++++++++------
compiler/typecheck/TcMType.hs | 2 +-
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/compiler/deSugar/DsBinds.hs b/compiler/deSugar/DsBinds.hs
index 143d209..4253255 100644
--- a/compiler/deSugar/DsBinds.hs
+++ b/compiler/deSugar/DsBinds.hs
@@ -895,7 +895,7 @@ Consider
After type checking the LHS becomes (foo alpha (C alpha)), where alpha
is an unbound meta-tyvar. The zonker in TcHsSyn is careful not to
turn the free alpha into Any (as it usually does). Instead it turns it
-into a skolem 'a'. See TcHsSyn Note [Zonking the LHS of a RULE].
+into a TyVar 'a'. See TcHsSyn Note [Zonking the LHS of a RULE].
Now we must quantify over that 'a'. It's /really/ inconvenient to do that
in the zonker, because the HsExpr data type is very large. But it's /easy/
diff --git a/compiler/typecheck/TcHsSyn.hs b/compiler/typecheck/TcHsSyn.hs
index 5a455ea..ebdc617 100644
--- a/compiler/typecheck/TcHsSyn.hs
+++ b/compiler/typecheck/TcHsSyn.hs
@@ -187,7 +187,9 @@ the environment manipulation is tiresome.
-- Confused by zonking? See Note [What is zonking?] in TcMType.
type UnboundTyVarZonker = TcTyVar -> TcM Type
-- How to zonk an unbound type variable
- -- The TcTyVar is (a) a MetaTv (b) Flexi and
+ -- The TcTyVar is
+ -- (a) a MetaTv
+ -- (b) Flexi and
-- (c) its kind is alrady zonked
-- Note [Zonking the LHS of a RULE]
@@ -1617,8 +1619,13 @@ zonkTvSkolemising :: UnboundTyVarZonker
-- This variant is used for the LHS of rules
-- See Note [Zonking the LHS of a RULE].
zonkTvSkolemising tv
- = do { tv' <- skolemiseUnboundMetaTyVar tv
- ; return (mkTyVarTy tv') }
+ = do { let tv' = mkTyVar (tyVarName tv) (tyVarKind tv)
+ -- NB: the kind of tv is already zonked
+ ty = mkTyVarTy tv'
+ -- Make a proper TyVar (remember we
+ -- are now done with type checking)
+ ; writeMetaTyVar tv ty
+ ; return ty }
zonkTypeZapping :: UnboundTyVarZonker
-- This variant is used for everything except the LHS of rules
@@ -1652,9 +1659,10 @@ over it!
We do this in two stages.
-* During zonking, we skolemise 'alpha' to 'a'. We do this by using
- zonkTvSkolemising as the UnboundTyVarZonker in the ZonkEnv.
- (This is the whole reason that the ZonkEnv has a UnboundTyVarZonker.)
+* During zonking, we skolemise the TcTyVar 'alpha' to TyVar 'a'. We
+ do this by using zonkTvSkolemising as the UnboundTyVarZonker in the
+ ZonkEnv. (This is in fact the whole reason that the ZonkEnv has a
+ UnboundTyVarZonker.)
* In DsBinds, we quantify over it. See DsBinds
Note [Free tyvars on rule LHS]
diff --git a/compiler/typecheck/TcMType.hs b/compiler/typecheck/TcMType.hs
index eae7305..b5104a1 100644
--- a/compiler/typecheck/TcMType.hs
+++ b/compiler/typecheck/TcMType.hs
@@ -68,7 +68,7 @@ module TcMType (
zonkTidyTcType, zonkTidyOrigin,
mkTypeErrorThing, mkTypeErrorThingArgs,
tidyEvVar, tidyCt, tidySkolemInfo,
- skolemiseUnboundMetaTyVar, skolemiseRuntimeUnk,
+ skolemiseRuntimeUnk,
zonkTcTyVar, zonkTcTyVars, zonkTcTyVarToTyVar,
zonkTyCoVarsAndFV, zonkTcTypeAndFV,
zonkTyCoVarsAndFVList,
More information about the ghc-commits
mailing list