summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Eisenberg <eir@cis.upenn.edu>2015-06-15 21:55:52 -0400
committerRichard Eisenberg <eir@cis.upenn.edu>2015-06-16 10:26:35 -0400
commit89c7168c150ccc38a2e6dd4a3aea555616722260 (patch)
tree76f5fa411d847d16ac3203c7c16e2c494e09771e
parent2613271ff2eee66c285fbfc5aa6ae22af44138fa (diff)
downloadhaskell-89c7168c150ccc38a2e6dd4a3aea555616722260.tar.gz
Fix #10534
Test case: typecheck/should_fail/T10534
-rw-r--r--compiler/types/TyCon.hs2
-rw-r--r--testsuite/tests/typecheck/should_fail/T10534.hs10
-rw-r--r--testsuite/tests/typecheck/should_fail/T10534.stderr22
-rw-r--r--testsuite/tests/typecheck/should_fail/T10534a.hs10
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T2
5 files changed, 45 insertions, 1 deletions
diff --git a/compiler/types/TyCon.hs b/compiler/types/TyCon.hs
index 827c076b2e..94fba284bf 100644
--- a/compiler/types/TyCon.hs
+++ b/compiler/types/TyCon.hs
@@ -1228,7 +1228,7 @@ isDistinctTyCon _ = False
isDistinctAlgRhs :: AlgTyConRhs -> Bool
isDistinctAlgRhs (TupleTyCon {}) = True
isDistinctAlgRhs (DataTyCon {}) = True
-isDistinctAlgRhs (DataFamilyTyCon {}) = True
+isDistinctAlgRhs (DataFamilyTyCon {}) = False
isDistinctAlgRhs (AbstractTyCon distinct) = distinct
isDistinctAlgRhs (NewTyCon {}) = False
diff --git a/testsuite/tests/typecheck/should_fail/T10534.hs b/testsuite/tests/typecheck/should_fail/T10534.hs
new file mode 100644
index 0000000000..ce694b4dca
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T10534.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE TypeFamilies #-}
+
+module T10534 where
+
+import T10534a
+
+newtype instance DF a = MkDF ()
+
+unsafeCoerce :: a -> b
+unsafeCoerce = silly
diff --git a/testsuite/tests/typecheck/should_fail/T10534.stderr b/testsuite/tests/typecheck/should_fail/T10534.stderr
new file mode 100644
index 0000000000..5f44426b5c
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T10534.stderr
@@ -0,0 +1,22 @@
+
+T10534a.hs:9:10: error:
+ Could not deduce: a ~ b
+ from the context: Coercible (DF a) (DF b)
+ bound by the type signature for:
+ silly :: Coercible (DF a) (DF b) => a -> b
+ at T10534a.hs:9:10-42
+ ‘a’ is a rigid type variable bound by
+ the type signature for: silly :: Coercible (DF a) (DF b) => a -> b
+ at T10534a.hs:9:10
+ ‘b’ is a rigid type variable bound by
+ the type signature for: silly :: Coercible (DF a) (DF b) => a -> b
+ at T10534a.hs:9:10
+ arising from trying to show that the representations of
+ ‘DF a’ and
+ ‘DF b’ are the same
+ Relevant role signatures: type role DF nominal
+ In the ambiguity check for the type signature for ‘silly’:
+ silly :: forall a b. Coercible (DF a) (DF b) => a -> b
+ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
+ In the type signature for ‘silly’:
+ silly :: Coercible (DF a) (DF b) => a -> b
diff --git a/testsuite/tests/typecheck/should_fail/T10534a.hs b/testsuite/tests/typecheck/should_fail/T10534a.hs
new file mode 100644
index 0000000000..4f53ebeb1f
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T10534a.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
+
+module T10534a where
+
+import Data.Coerce
+
+data family DF a
+
+silly :: Coercible (DF a) (DF b) => a -> b
+silly = coerce
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index 4dfc220c58..eeb410f0ef 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -365,3 +365,5 @@ test('T10285',
extra_clean(['T10285a.hi', 'T10285a.o']),
multimod_compile_fail, ['T10285', '-v0'])
test('T10351', normal, compile_fail, [''])
+test('T10534', extra_clean(['T10534a.hi', 'T10534a.o']),
+ multimod_compile_fail, ['T10534', '-v0'])