[commit: ghc] master: Testsuite: add typecheck/should_fail/T9260 (#9260) (58b5f04)
git at git.haskell.org
git at git.haskell.org
Thu Jul 30 20:54:35 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/58b5f04483258e55b93390fbf5ce41a1dbe23340/ghc
>---------------------------------------------------------------
commit 58b5f04483258e55b93390fbf5ce41a1dbe23340
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date: Mon Jul 27 22:07:00 2015 +0200
Testsuite: add typecheck/should_fail/T9260 (#9260)
>---------------------------------------------------------------
58b5f04483258e55b93390fbf5ce41a1dbe23340
testsuite/tests/typecheck/should_fail/T9260.hs | 34 ++++++++++++++++++++++
testsuite/tests/typecheck/should_fail/T9260.stderr | 8 +++++
testsuite/tests/typecheck/should_fail/all.T | 1 +
3 files changed, 43 insertions(+)
diff --git a/testsuite/tests/typecheck/should_fail/T9260.hs b/testsuite/tests/typecheck/should_fail/T9260.hs
new file mode 100644
index 0000000..23c19c7
--- /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 0000000..4d1a94a
--- /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 bc2b3c9..3fdc38b 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, [''])
More information about the ghc-commits
mailing list