summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2022-11-02 18:06:35 +0000
committerSimon Peyton Jones <simon.peytonjones@gmail.com>2022-11-25 22:31:27 +0000
commitd10dc6bdade0fdae879e5869038ce8378c2ce84f (patch)
treee386af2c82a9e64b7c72275c2b7e9af36bea7f11 /testsuite/tests
parent13d627bbd0bc3dd30d672de341aa7f471be0aa2c (diff)
downloadhaskell-d10dc6bdade0fdae879e5869038ce8378c2ce84f.tar.gz
Fix decomposition of TyConAppswip/T22331
Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions.
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/typecheck/should_compile/T22331.hs15
-rw-r--r--testsuite/tests/typecheck/should_compile/all.T1
2 files changed, 16 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/T22331.hs b/testsuite/tests/typecheck/should_compile/T22331.hs
new file mode 100644
index 0000000000..0454c97d7d
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T22331.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE TypeFamilies #-}
+
+module T22331 where
+
+import Data.Coerce
+
+data family Fool a
+
+-- This works
+joe :: Coercible (Fool a) (Fool b) => Fool a -> Fool b
+joe = coerce
+
+-- This does not
+bob :: Coercible (Fool a) (Fool b) => Fool b -> Fool a
+bob = coerce
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index 80738de7c1..46db37f854 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -850,3 +850,4 @@ test('T21951a', normal, compile, ['-Wredundant-strictness-flags'])
test('T21951b', normal, compile, ['-Wredundant-strictness-flags'])
test('T21550', normal, compile, [''])
test('T22310', normal, compile, [''])
+test('T22331', normal, compile, [''])