diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2019-07-03 08:55:26 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-07-04 21:23:49 -0400 |
commit | 53aa59f36dc6554c37ead9677c71e91cad3f9f21 (patch) | |
tree | ce78eedab239b1ec96e0e78d7ebba5b1f3fee5e5 /testsuite/tests/polykinds | |
parent | 679427f878e50ba5a9981bac4c2f9c76f4de3c3c (diff) | |
download | haskell-53aa59f36dc6554c37ead9677c71e91cad3f9f21.tar.gz |
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’
Diffstat (limited to 'testsuite/tests/polykinds')
-rw-r--r-- | testsuite/tests/polykinds/T16902.hs | 11 | ||||
-rw-r--r-- | testsuite/tests/polykinds/T16902.stderr | 6 | ||||
-rw-r--r-- | testsuite/tests/polykinds/all.T | 1 |
3 files changed, 18 insertions, 0 deletions
diff --git a/testsuite/tests/polykinds/T16902.hs b/testsuite/tests/polykinds/T16902.hs new file mode 100644 index 0000000000..70fc7bd742 --- /dev/null +++ b/testsuite/tests/polykinds/T16902.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE TypeOperators #-} +module Bug where + +import Data.Kind +import Data.Type.Equality + +data F (a :: k) :: (a ~~ k) => Type where + MkF :: F a diff --git a/testsuite/tests/polykinds/T16902.stderr b/testsuite/tests/polykinds/T16902.stderr new file mode 100644 index 0000000000..e265866119 --- /dev/null +++ b/testsuite/tests/polykinds/T16902.stderr @@ -0,0 +1,6 @@ + +T16902.hs:11:10: error: + • Expected a type, but found something with kind ‘a1’ + • In the type ‘F a’ + In the definition of data constructor ‘MkF’ + In the data declaration for ‘F’ diff --git a/testsuite/tests/polykinds/all.T b/testsuite/tests/polykinds/all.T index 5a90ebe723..c67d80d621 100644 --- a/testsuite/tests/polykinds/all.T +++ b/testsuite/tests/polykinds/all.T @@ -211,3 +211,4 @@ test('T16221', normal, compile, ['']) test('T16221a', normal, compile_fail, ['']) test('T16342', normal, compile, ['']) test('T16263', normal, compile_fail, ['']) +test('T16902', normal, compile_fail, ['']) |