Add a missing zonk (fixes #16902)
In the eager unifier, when unifying (tv1 ~ tv2), when we decide to swap them over, to unify (tv2 ~ tv1), I'd forgotten to ensure that tv1's kind was fully zonked, which is an invariant of uUnfilledTyVar2. That could lead us to build an infinite kind, or (in the case of #16902) update the same unification variable twice. Yikes. Now we get an error message rather than non-termination, which is much better. The error message is not great, but it's a very strange program, and I can't see an easy way to improve it, so for now I'm just committing this fix. Here's the decl data F (a :: k) :: (a ~~ k) => Type where MkF :: F a and the rather error message of which I am not proud T16902.hs:11:10: error: • Expected a type, but found something with kind ‘a1’ • In the type ‘F a’
Showing
- compiler/typecheck/TcUnify.hs 22 additions, 10 deletionscompiler/typecheck/TcUnify.hs
- testsuite/tests/polykinds/T16902.hs 11 additions, 0 deletionstestsuite/tests/polykinds/T16902.hs
- testsuite/tests/polykinds/T16902.stderr 6 additions, 0 deletionstestsuite/tests/polykinds/T16902.stderr
- testsuite/tests/polykinds/all.T 1 addition, 0 deletionstestsuite/tests/polykinds/all.T
testsuite/tests/polykinds/T16902.hs
0 → 100644
testsuite/tests/polykinds/T16902.stderr
0 → 100644
Please register or sign in to comment