Add (failing) test case for #11347
authorJoachim Breitner <mail@joachim-breitner.de>
Tue, 5 Jan 2016 09:56:47 +0000 (10:56 +0100)
committerJoachim Breitner <mail@joachim-breitner.de>
Tue, 5 Jan 2016 09:56:47 +0000 (10:56 +0100)
Unfortunately, I could not add the expected error message, so if someone
accidentally fixes this bug, this test will still be failing (no harm).
But maybe someone stumbles over it then and can update the expected
output.

testsuite/tests/typecheck/should_fail/T11347.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T11347.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/all.T

diff --git a/testsuite/tests/typecheck/should_fail/T11347.hs b/testsuite/tests/typecheck/should_fail/T11347.hs
new file mode 100644 (file)
index 0000000..eaffdfd
--- /dev/null
@@ -0,0 +1,19 @@
+-- Should AllowAmbiguousTypes relaly be needed here?
+{-# LANGUAGE TypeFamilies, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleInstances, AllowAmbiguousTypes #-}
+module T11347 where
+
+newtype Id1 a = MkId1 a
+newtype Id2 a = MkId2 (Id1 a) deriving (UnsafeCast b)
+
+type family Discern a b
+type instance Discern (Id1 a) b = a
+type instance Discern (Id2 a) b = b
+
+class UnsafeCast to from where
+  unsafe :: from -> Discern from to
+
+instance UnsafeCast b (Id1 a) where
+  unsafe (MkId1 x) = x
+
+unsafeCoerce :: a -> b
+unsafeCoerce x = unsafe (MkId2 (MkId1 x))
diff --git a/testsuite/tests/typecheck/should_fail/T11347.stderr b/testsuite/tests/typecheck/should_fail/T11347.stderr
new file mode 100644 (file)
index 0000000..1de61cd
--- /dev/null
@@ -0,0 +1,2 @@
+dummy stderr:
+here should be something about roles _not_ "No skolem info"
index 4279950..93dd0c7 100644 (file)
@@ -398,3 +398,4 @@ test('T11112', normal, compile_fail, [''])
 test('ClassOperator', normal, compile_fail, [''])
 test('T11274', normal, compile_fail, [''])
 test('T10619', normal, compile_fail, [''])
+test('T11347', expect_broken(11347), compile_fail, [''])