summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorJoachim Breitner <mail@joachim-breitner.de>2015-07-28 13:19:34 +0200
committerJoachim Breitner <mail@joachim-breitner.de>2015-07-28 13:23:07 +0200
commite343c0a7fbaca4285a89008e5e23d35a50603763 (patch)
tree2db48112d6810464ed69c3ec8ff8a83026d3918d /testsuite
parenta1e8620fa2840f1f18297d784a2d2b174b27f566 (diff)
downloadhaskell-e343c0a7fbaca4285a89008e5e23d35a50603763.tar.gz
Test case for #10698
the expected error message is from an older version of GHC; I don’t know the exact error message that we should get here until the bug is fixed...
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/typecheck/should_fail/T10698.hs23
-rw-r--r--testsuite/tests/typecheck/should_fail/T10698.stderr10
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T1
3 files changed, 34 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/T10698.hs b/testsuite/tests/typecheck/should_fail/T10698.hs
new file mode 100644
index 0000000000..512a882da4
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T10698.hs
@@ -0,0 +1,23 @@
+{-# LANGUAGE RoleAnnotations #-}
+
+module T10698 where
+import Data.Coerce
+
+data Map k a = Map k a
+type role Map nominal representational
+
+map1 :: (k1->k2) -> Map k1 a -> Map k2 a
+map1 f (Map a b) = Map (f a) b
+{-# NOINLINE [1] map1 #-}
+{-# RULES
+"map1/coerce" map1 coerce = coerce
+ #-}
+
+
+map2 :: (a -> b) -> Map k a -> Map k b
+map2 f (Map a b) = Map a (f b)
+{-# NOINLINE [1] map2 #-}
+
+{-# RULES
+"map2/coerce" map2 coerce = coerce
+ #-}
diff --git a/testsuite/tests/typecheck/should_fail/T10698.stderr b/testsuite/tests/typecheck/should_fail/T10698.stderr
new file mode 100644
index 0000000000..fa3aa5fd5a
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T10698.stderr
@@ -0,0 +1,10 @@
+
+T10698.hs:13:29:
+ Could not coerce from ‘Map k1 a’ to ‘Map k2 a’
+ because the first type argument of ‘Map’ has role Nominal,
+ but the arguments ‘k1’ and ‘k2’ differ
+ arising from a use of ‘coerce’
+ from the context (Coercible k1 k2)
+ bound by the RULE "map1/coerce" at T10698.hs:13:1-34
+ In the expression: coerce
+ When checking the transformation rule "map1/coerce"
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index fbbeddbbe0..bc2b3c98f1 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -374,3 +374,4 @@ test('ExpandSynsFail1', normal, compile_fail, ['-fprint-expanded-synonyms'])
test('ExpandSynsFail2', normal, compile_fail, ['-fprint-expanded-synonyms'])
test('ExpandSynsFail3', normal, compile_fail, ['-fprint-expanded-synonyms'])
test('ExpandSynsFail4', normal, compile_fail, ['-fprint-expanded-synonyms'])
+test('T10698', expect_broken(10698), compile_fail, [''])