Testsuite: add typecheck/should_fail/T9260 (#9260)
authorThomas Miedema <thomasmiedema@gmail.com>
Mon, 27 Jul 2015 20:07:00 +0000 (22:07 +0200)
committerThomas Miedema <thomasmiedema@gmail.com>
Thu, 30 Jul 2015 20:53:13 +0000 (22:53 +0200)
testsuite/tests/typecheck/should_fail/T9260.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T9260.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/all.T

diff --git a/testsuite/tests/typecheck/should_fail/T9260.hs b/testsuite/tests/typecheck/should_fail/T9260.hs
new file mode 100644 (file)
index 0000000..23c19c7
--- /dev/null
@@ -0,0 +1,34 @@
+{-# LANGUAGE DataKinds, TypeOperators, GADTs #-}
+
+module T9260 where
+
+import GHC.TypeLits
+
+data Fin n where
+  Fzero :: Fin (n + 1)
+  Fsucc :: Fin n -> Fin (n + 1)
+
+test :: Fin 1
+test = Fsucc Fzero
+
+{- Only the second error is legitimate.
+
+% ghc --version
+The Glorious Glasgow Haskell Compilation System, version 7.8.2
+% ghc -ignore-dot-ghci /tmp/Error.hs
+[1 of 1] Compiling Error            ( /tmp/Error.hs, /tmp/Error.o )
+
+/tmp/Error.hs:12:8:
+    Couldn't match type ‘0’ with ‘1’
+    Expected type: Fin 1
+      Actual type: Fin (0 + 1)
+    In the expression: Fsucc Fzero
+    In an equation for ‘test’: test = Fsucc Fzero
+
+/tmp/Error.hs:12:14:
+    Couldn't match type ‘1’ with ‘0’
+    Expected type: Fin 0
+      Actual type: Fin (0 + 1)
+    In the first argument of ‘Fsucc’, namely ‘Fzero’
+    In the expression: Fsucc Fzero
+-}
diff --git a/testsuite/tests/typecheck/should_fail/T9260.stderr b/testsuite/tests/typecheck/should_fail/T9260.stderr
new file mode 100644 (file)
index 0000000..4d1a94a
--- /dev/null
@@ -0,0 +1,8 @@
+
+T9260.hs:12:8: error:
+    Couldn't match type ‘(n0 + 1) + 1’ with ‘1’
+    The type variable ‘n0’ is ambiguous
+    Expected type: Fin 1
+      Actual type: Fin ((n0 + 1) + 1)
+    In the expression: Fsucc Fzero
+    In an equation for ‘test’: test = Fsucc Fzero
index bc2b3c9..3fdc38b 100644 (file)
@@ -341,6 +341,7 @@ test('T8912', normal, compile_fail, [''])
 test('T9033', normal, compile_fail, [''])
 test('T8883', normal, compile_fail, [''])
 test('T9196', normal, compile_fail, [''])
+test('T9260', normal, compile_fail, [''])
 test('T9305', normal, compile_fail, [''])
 test('T9323', normal, compile_fail, [''])
 test('T9415', normal, compile_fail, [''])