diff options
author | Richard Eisenberg <rae@cs.brynmawr.edu> | 2018-07-17 00:12:34 -0400 |
---|---|---|
committer | Richard Eisenberg <rae@cs.brynmawr.edu> | 2018-08-01 12:12:22 -0400 |
commit | f8618a9b15177ee8c84771b927cb3583c9cd8408 (patch) | |
tree | d8abc1b82308735a80721b900372a8eb3e5db56d /compiler/iface | |
parent | 1df50a0f61f320428f2e6dd07b3c9ce49c4acd31 (diff) | |
download | haskell-f8618a9b15177ee8c84771b927cb3583c9cd8408.tar.gz |
Remove the type-checking knot.
Bug #15380 hangs because a knot-tied TyCon ended up in a kind.
Looking at the code in tcInferApps, I'm amazed this hasn't happened
before! I couldn't think of a good way to fix it (with dependent
types, we can't really keep types out of kinds, after all), so
I just went ahead and removed the knot.
This was remarkably easy to do. In tcTyVar, when we find a TcTyCon,
just use it. (Previously, we looked up the knot-tied TyCon and used
that.) Then, during the final zonk, replace TcTyCons with the real,
full-blooded TyCons in the global environment. It's all very easy.
The new bit is explained in the existing
Note [Type checking recursive type and class declarations]
in TcTyClsDecls.
Naturally, I removed various references to the knot and the
zonkTcTypeInKnot (and related) functions. Now, we can print types
during type checking with abandon!
NB: There is a teensy error message regression with this patch,
around the ordering of quantified type variables. This ordering
problem is fixed (I believe) with the patch for #14880. The ordering
affects only internal variables that cannot be instantiated with
any kind of visible type application.
There is also a teensy regression around the printing of types
in TH splices. I think this is really a TH bug and will file
separately.
Test case: dependent/should_fail/T15380
Diffstat (limited to 'compiler/iface')
-rw-r--r-- | compiler/iface/BuildTyCl.hs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/compiler/iface/BuildTyCl.hs b/compiler/iface/BuildTyCl.hs index 43e9408430..3ddd355a6d 100644 --- a/compiler/iface/BuildTyCl.hs +++ b/compiler/iface/BuildTyCl.hs @@ -8,7 +8,7 @@ module BuildTyCl ( buildDataCon, buildPatSyn, - TcMethInfo, buildClass, + TcMethInfo, MethInfo, buildClass, mkNewTyConRhs, newImplicitBinder, newTyConRepName ) where @@ -104,10 +104,11 @@ buildDataCon :: FamInstEnvs -> [TyVar] -- Existentials -> [TyVarBinder] -- User-written 'TyVarBinder's -> [EqSpec] -- Equality spec - -> ThetaType -- Does not include the "stupid theta" + -> KnotTied ThetaType -- Does not include the "stupid theta" -- or the GADT equalities - -> [Type] -> Type -- Argument and result types - -> TyCon -- Rep tycon + -> [KnotTied Type] -- Arguments + -> KnotTied Type -- Result types + -> KnotTied TyCon -- Rep tycon -> NameEnv ConTag -- Maps the Name of each DataCon to its -- ConTag -> TcRnIf m n DataCon @@ -213,7 +214,8 @@ buildPatSyn src_name declared_infix matcher@(matcher_id,_) builder ------------------------------------------------------ -type TcMethInfo -- A temporary intermediate, to communicate +type TcMethInfo = MethInfo -- this variant needs zonking +type MethInfo -- A temporary intermediate, to communicate -- between tcClassSigs and buildClass. = ( Name -- Name of the class op , Type -- Type of the class op @@ -237,7 +239,7 @@ buildClass :: Name -- Name of the class/tycon (they have the same Name) -> [FunDep TyVar] -- Functional dependencies -- Super classes, associated types, method info, minimal complete def. -- This is Nothing if the class is abstract. - -> Maybe (ThetaType, [ClassATItem], [TcMethInfo], ClassMinimalDef) + -> Maybe (KnotTied ThetaType, [ClassATItem], [KnotTied MethInfo], ClassMinimalDef) -> TcRnIf m n Class buildClass tycon_name binders roles fds Nothing |