Add tests for #11391
authorBen Gamari <ben@smart-cactus.org>
Thu, 14 Jan 2016 10:27:37 +0000 (11:27 +0100)
committerBen Gamari <ben@smart-cactus.org>
Thu, 14 Jan 2016 11:00:00 +0000 (12:00 +0100)
testsuite/tests/typecheck/should_fail/CustomTypeErrors04.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/CustomTypeErrors04.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/CustomTypeErrors05.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/CustomTypeErrors05.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/all.T

diff --git a/testsuite/tests/typecheck/should_fail/CustomTypeErrors04.hs b/testsuite/tests/typecheck/should_fail/CustomTypeErrors04.hs
new file mode 100644 (file)
index 0000000..d1957bf
--- /dev/null
@@ -0,0 +1,14 @@
+{-# LANGUAGE TypeInType, TypeFamilies, UndecidableInstances #-}
+{-# LANGUAGE UndecidableInstances #-}
+
+-- The "bad case" in #11391
+module CustomTypeErrors04 where
+
+import Data.Kind
+import GHC.TypeLits (TypeError, ErrorMessage(..))
+
+type family Resolve (t :: Type -> Type) :: Type -> Type where
+  Resolve _ = TypeError (Text "ERROR")
+
+testNOTOK1 :: Resolve [] Int
+testNOTOK1 = ()
diff --git a/testsuite/tests/typecheck/should_fail/CustomTypeErrors04.stderr b/testsuite/tests/typecheck/should_fail/CustomTypeErrors04.stderr
new file mode 100644 (file)
index 0000000..9bec37b
--- /dev/null
@@ -0,0 +1,5 @@
+
+CustomTypeErrors04.hs:14:14: error:
+    • ERROR
+    • In the expression: ()
+      In an equation for ‘testNOTOK1’: testNOTOK1 = ()
diff --git a/testsuite/tests/typecheck/should_fail/CustomTypeErrors05.hs b/testsuite/tests/typecheck/should_fail/CustomTypeErrors05.hs
new file mode 100644 (file)
index 0000000..5a15b6f
--- /dev/null
@@ -0,0 +1,14 @@
+{-# LANGUAGE TypeInType, TypeFamilies, UndecidableInstances #-}
+{-# LANGUAGE UndecidableInstances #-}
+
+-- The "tricky case" in #11391
+module CustomTypeErrors05 where
+
+import Data.Kind
+import GHC.TypeLits (TypeError, ErrorMessage(..))
+
+type family Resolve (t :: Type -> Type) :: Type -> Type where
+  Resolve _ = TypeError (Text "ERROR")
+
+testNOTOK2 :: Resolve [] Int
+testNOTOK2 = 1
diff --git a/testsuite/tests/typecheck/should_fail/CustomTypeErrors05.stderr b/testsuite/tests/typecheck/should_fail/CustomTypeErrors05.stderr
new file mode 100644 (file)
index 0000000..3164c86
--- /dev/null
@@ -0,0 +1,5 @@
+
+CustomTypeErrors05.hs:14:14: error:
+    • ERROR
+    • In the expression: 1
+      In an equation for ‘testNOTOK2’: testNOTOK2 = 1
index 753708d..9aef820 100644 (file)
@@ -394,6 +394,8 @@ test('T10971d', extra_clean(['T10971c.hi', 'T10971c.o']), multimod_compile_fail,
 test('CustomTypeErrors01', normal, compile_fail, [''])
 test('CustomTypeErrors02', normal, compile_fail, [''])
 test('CustomTypeErrors03', normal, compile_fail, [''])
+test('CustomTypeErrors04', normal, compile_fail, [''])
+test('CustomTypeErrors05', normal, compile_fail, [''])
 test('T11112', normal, compile_fail, [''])
 test('ClassOperator', normal, compile_fail, [''])
 test('T11274', normal, compile_fail, [''])