summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorThomas Miedema <thomasmiedema@gmail.com>2015-07-27 22:07:00 +0200
committerThomas Miedema <thomasmiedema@gmail.com>2015-07-30 22:53:13 +0200
commit58b5f04483258e55b93390fbf5ce41a1dbe23340 (patch)
tree8a4ca64b002a8c20f51acc6475f8190c387470fb /testsuite
parent6880277381061593da2c2c19767ba508fb4045e3 (diff)
downloadhaskell-58b5f04483258e55b93390fbf5ce41a1dbe23340.tar.gz
Testsuite: add typecheck/should_fail/T9260 (#9260)
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/typecheck/should_fail/T9260.hs34
-rw-r--r--testsuite/tests/typecheck/should_fail/T9260.stderr8
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T1
3 files changed, 43 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/T9260.hs b/testsuite/tests/typecheck/should_fail/T9260.hs
new file mode 100644
index 0000000000..23c19c76bb
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T9260.hs
@@ -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
index 0000000000..4d1a94a4bd
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T9260.stderr
@@ -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
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index bc2b3c98f1..3fdc38b559 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -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, [''])