diff options
| -rw-r--r-- | compiler/types/TyCon.hs | 2 | ||||
| -rw-r--r-- | testsuite/tests/typecheck/should_fail/T10534.hs | 10 | ||||
| -rw-r--r-- | testsuite/tests/typecheck/should_fail/T10534.stderr | 22 | ||||
| -rw-r--r-- | testsuite/tests/typecheck/should_fail/T10534a.hs | 10 | ||||
| -rw-r--r-- | testsuite/tests/typecheck/should_fail/all.T | 2 |
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']) |
