summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simon.peytonjones@gmail.com>2022-12-19 22:58:07 +0000
committerZubin Duggal <zubin.duggal@gmail.com>2023-02-07 18:47:09 +0530
commitc63a3e25e9265851beefef99a30cbfe29136a254 (patch)
treea0ca210221386cb699a63cf4d6f2fb92cebce801
parent27f154f9c68b2c64107eb64104d9eb92295191c6 (diff)
downloadhaskell-c63a3e25e9265851beefef99a30cbfe29136a254.tar.gz
Fix an assertion check in addToEqualCtList
The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645 (cherry picked from commit 3d55d8ab51ece43c51055c43c9e7aba77cce46c0)
-rw-r--r--testsuite/tests/typecheck/should_fail/T22645.hs9
-rw-r--r--testsuite/tests/typecheck/should_fail/T22645.stderr15
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T1
3 files changed, 25 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/T22645.hs b/testsuite/tests/typecheck/should_fail/T22645.hs
new file mode 100644
index 0000000000..ee5f03d180
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T22645.hs
@@ -0,0 +1,9 @@
+module T22645 where
+
+import Data.Coerce
+
+type T :: (* -> *) -> * -> *
+data T m a = MkT (m a)
+
+p :: Coercible a b => T Maybe a -> T Maybe b
+p = coerce
diff --git a/testsuite/tests/typecheck/should_fail/T22645.stderr b/testsuite/tests/typecheck/should_fail/T22645.stderr
new file mode 100644
index 0000000000..5844a67dce
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T22645.stderr
@@ -0,0 +1,15 @@
+
+T22645.hs:9:5: error:
+ • Couldn't match type ‘a’ with ‘b’ arising from a use of ‘coerce’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ p :: forall a b. Coercible a b => T Maybe a -> T Maybe b
+ at T22645.hs:8:1-44
+ ‘b’ is a rigid type variable bound by
+ the type signature for:
+ p :: forall a b. Coercible a b => T Maybe a -> T Maybe b
+ at T22645.hs:8:1-44
+ • In the expression: coerce
+ In an equation for ‘p’: p = coerce
+ • Relevant bindings include
+ p :: T Maybe a -> T Maybe b (bound at T22645.hs:9:1)
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index 358999c612..04fb804d33 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -629,3 +629,4 @@ test('T19397E4', extra_files(['T19397S.hs']), multimod_compile_fail,
test('T20043', normal, compile_fail, [''])
test('T20260', normal, compile_fail, [''])
test('T21130', normal, compile_fail, [''])
+test('T22645', normal, compile_fail, [''])