testsuite: Add testcase for #16394
authorBen Gamari <ben@smart-cactus.org>
Wed, 6 Mar 2019 01:33:51 +0000 (20:33 -0500)
committerBen Gamari <ben@smart-cactus.org>
Thu, 14 Mar 2019 16:20:50 +0000 (12:20 -0400)
testsuite/tests/typecheck/should_fail/T16394.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T16394.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/all.T

diff --git a/testsuite/tests/typecheck/should_fail/T16394.hs b/testsuite/tests/typecheck/should_fail/T16394.hs
new file mode 100644 (file)
index 0000000..76ca7a7
--- /dev/null
@@ -0,0 +1,12 @@
+{-# LANGUAGE PolyKinds, TypeFamilies, DataKinds #-}
+
+class C a where
+    type T (n :: a)
+
+instance C a => C b => C (a, b) where
+    type T '(n, m) = (T n, T m)
+
+-- but this worked fine:
+--
+-- instance (C a, C b) => C (a, b) where
+--   type T '(n, m) = (T n, T m)
diff --git a/testsuite/tests/typecheck/should_fail/T16394.stderr b/testsuite/tests/typecheck/should_fail/T16394.stderr
new file mode 100644 (file)
index 0000000..fff51a6
--- /dev/null
@@ -0,0 +1,5 @@
+T16394.hs:6:10: error:
+    Illegal class instance: ā€˜C a => C b => C (a, b)ā€™
+      Class instances must be of the form
+        context => C ty_1 ... ty_n
+      where ā€˜Cā€™ is a class
index b3c25ea..bd13b2f 100644 (file)
@@ -510,4 +510,5 @@ test('T16059e', [extra_files(['T16059b.hs'])], multimod_compile_fail,
     ['T16059e', '-v0'])
 test('T16255', normal, compile_fail, [''])
 test('T16204c', normal, compile_fail, [''])
+test('T16394', normal, compile_fail, [''])
 test('T16414', normal, compile_fail, [''])