Two tests for Trac #14230
authorSimon Peyton Jones <simonpj@microsoft.com>
Fri, 30 Nov 2018 14:00:14 +0000 (14:00 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Fri, 30 Nov 2018 14:00:38 +0000 (14:00 +0000)
testsuite/tests/indexed-types/should_fail/T14230.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T14230.stderr [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T14230a.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T14230a.stderr [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/all.T

diff --git a/testsuite/tests/indexed-types/should_fail/T14230.hs b/testsuite/tests/indexed-types/should_fail/T14230.hs
new file mode 100644 (file)
index 0000000..d409ba6
--- /dev/null
@@ -0,0 +1,11 @@
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE PolyKinds #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE TypeFamilies #-}
+module T14230 where
+
+class C k where
+  data CD :: k -> k -> *
+
+instance C (Maybe a) where
+  data CD :: (k -> *) -> (k -> *) -> *
diff --git a/testsuite/tests/indexed-types/should_fail/T14230.stderr b/testsuite/tests/indexed-types/should_fail/T14230.stderr
new file mode 100644 (file)
index 0000000..174a15a
--- /dev/null
@@ -0,0 +1,7 @@
+
+T14230.hs:11:3: error:
+    • Type indexes must match class instance head
+      Expected: CD @(Maybe a)
+        Actual: CD @(k -> *) -- Defined at T14230.hs:11:8
+    • In the data instance declaration for ‘CD’
+      In the instance declaration for ‘C (Maybe a)’
diff --git a/testsuite/tests/indexed-types/should_fail/T14230a.hs b/testsuite/tests/indexed-types/should_fail/T14230a.hs
new file mode 100644 (file)
index 0000000..84cd6f1
--- /dev/null
@@ -0,0 +1,13 @@
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE TypeInType #-}
+module T14230a where
+
+import Data.Kind
+
+class C a where
+  data CD k (a :: k) :: k -> *
+
+instance C (Maybe a) where
+  data CD k (a :: k -> *) :: (k -> *) -> *
diff --git a/testsuite/tests/indexed-types/should_fail/T14230a.stderr b/testsuite/tests/indexed-types/should_fail/T14230a.stderr
new file mode 100644 (file)
index 0000000..726764a
--- /dev/null
@@ -0,0 +1,6 @@
+
+T14230a.hs:13:14: error:
+    • Expected kind ‘k -> *’, but ‘a’ has kind ‘*’
+    • In the second argument of ‘CD’, namely ‘(a :: k -> *)’
+      In the data instance declaration for ‘CD’
+      In the instance declaration for ‘C (Maybe a)’
index 6273f59..4f6863b 100644 (file)
@@ -152,3 +152,5 @@ test('T15740', normal, compile_fail, [''])
 test('T15764', normal, compile_fail, [''])
 test('T15870', normal, compile_fail, [''])
 test('T14887', normal, compile_fail, [''])
+test('T14230', normal, compile_fail, [''])
+test('T14230a', normal, compile_fail, [''])