summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2022-10-19 01:09:09 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-10-19 10:50:37 -0400
commitb17cfc9c4b341e122294c0701803fc8f521fa210 (patch)
tree67ad2295fb6aa2d9ca11f223f189165ad30caf68 /testsuite/tests
parent1dab116784e480ab277623e1bd8d78beadcbc433 (diff)
downloadhaskell-b17cfc9c4b341e122294c0701803fc8f521fa210.tar.gz
TyEq:N assertion: only for saturated applications
The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/typecheck/should_compile/T22310.hs23
-rw-r--r--testsuite/tests/typecheck/should_compile/all.T1
2 files changed, 24 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/T22310.hs b/testsuite/tests/typecheck/should_compile/T22310.hs
new file mode 100644
index 0000000000..9605a674be
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T22310.hs
@@ -0,0 +1,23 @@
+{-# LANGUAGE GADTs, ScopedTypeVariables, StandaloneKindSignatures #-}
+
+module T22310 where
+
+import Data.Coerce ( coerce )
+import Data.Kind ( Type )
+
+type Some :: (Type -> Type) -> Type
+data Some t where
+ Some :: t ex -> Some t
+
+type NT :: Type -> Type
+newtype NT f = MkNT ()
+
+oops :: Some NT -> Some NT
+oops = coerce (\(Some @NT x) -> Some x)
+ -- After canonicalisation of Wanted constraints,
+ -- we end up with:
+ --
+ -- [W] t[tau:0] ~R# NT
+ --
+ -- Note the newtype TyCon on the RHS.
+ -- Does not violate TyEq:N, because it is unsaturated!
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index 802eb9097d..c1b10ff6c8 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -856,3 +856,4 @@ test('DeepSubsumption09', normal, compile, [''])
test('T21951a', normal, compile, ['-Wredundant-strictness-flags'])
test('T21951b', normal, compile, ['-Wredundant-strictness-flags'])
test('T21550', normal, compile, [''])
+test('T22310', normal, compile, [''])