diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2021-03-13 23:46:50 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-03-31 11:12:52 -0400 |
commit | dbadd672ba7da67533c34d8594ac7f91dde0f415 (patch) | |
tree | 4c40cc05d77aa270d754c4090ebcaa1fbe62d8f4 /compiler/GHC/Tc/Utils | |
parent | 44774dc591206291d06e6181f599151631062332 (diff) | |
download | haskell-dbadd672ba7da67533c34d8594ac7f91dde0f415.tar.gz |
The result kind of a signature can't mention quantified vars
This patch fixes a small but egregious bug, which allowed
a type signature like
f :: forall a. blah
not to fail if (blah :: a). Acutally this only showed
up as a ASSERT error (#19495).
The fix is very short, but took quite a bit of head scratching
Hence the long Note [Escaping kind in type signatures]
While I was in town, I also added a short-cut for the
common case of having no quantifiers to tcImplicitTKBndrsX.
Metric Decrease:
T9198
Metric Increase:
T9198
Diffstat (limited to 'compiler/GHC/Tc/Utils')
-rw-r--r-- | compiler/GHC/Tc/Utils/TcMType.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/GHC/Tc/Utils/TcMType.hs b/compiler/GHC/Tc/Utils/TcMType.hs index b6f5065997..519a2b37a8 100644 --- a/compiler/GHC/Tc/Utils/TcMType.hs +++ b/compiler/GHC/Tc/Utils/TcMType.hs @@ -1252,6 +1252,9 @@ skolems are in scope within the type itself (e.g. that 'forall arg'). This change is inspired by and described in Section 7.2 of "Kind Inference for Datatypes", POPL'20. +NB: this is all rather similar to, but sadly not the same as + Note [Error on unconstrained meta-variables] + Wrinkle: We must make absolutely sure that alpha indeed is not @@ -1919,6 +1922,9 @@ on kappa. What to do? We choose (D), as described in #17567. Discussion of alternatives is below. +NB: this is all rather similar to, but sadly not the same as + Note [Naughty quantification candidates] + (One last example: type instance F Int = Proxy Any, where the unconstrained kind variable is the inferred kind of Any. The four examples here illustrate all cases in which this Note applies.) @@ -1998,6 +2004,7 @@ doNotQuantifyTyVars :: CandidatesQTvs -> (TidyEnv -> TcM (TidyEnv, SDoc)) -- ^ like "the class context (D a b, E foogle)" -> TcM () +-- See Note [Error on unconstrained meta-variables] doNotQuantifyTyVars dvs where_found | isEmptyCandidates dvs = traceTc "doNotQuantifyTyVars has nothing to error on" empty |