summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2023-05-11 14:31:57 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-05-12 19:28:00 -0400
commitd683b2e5b91a39a2bf16796f5800f605a0281004 (patch)
treee9d561ed4b7901c62fcb949d9181e169f6af9952 /testsuite
parent5ad776abbb7c72d65d2ae27de5b2ec48b6e72cde (diff)
downloadhaskell-d683b2e5b91a39a2bf16796f5800f605a0281004.tar.gz
Fix coercion optimisation for SelCo (#23362)
setNominalRole_maybe is supposed to output a nominal coercion. In the SelCo case, it was not updating the stored role to Nominal, causing #23362.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/simplCore/should_compile/T23362.hs21
-rw-r--r--testsuite/tests/simplCore/should_compile/all.T1
2 files changed, 22 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_compile/T23362.hs b/testsuite/tests/simplCore/should_compile/T23362.hs
new file mode 100644
index 0000000000..5c096d9f89
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T23362.hs
@@ -0,0 +1,21 @@
+module T23362 where
+
+import Unsafe.Coerce
+import Data.Kind
+
+type Phantom :: Type -> Type
+data Phantom a = MkPhantom
+
+newtype Id a = MkId a
+newtype First a = MkFirst (Id a)
+data Second a = MkSecond (First a)
+data Third a = MkThird !(Second a)
+
+a :: Second (Phantom Int)
+a = MkSecond (MkFirst (MkId MkPhantom))
+
+uc :: Second (Phantom Int) -> Second (Phantom Bool)
+uc = unsafeCoerce
+
+b :: Third (Phantom Bool)
+b = MkThird (uc a)
diff --git a/testsuite/tests/simplCore/should_compile/all.T b/testsuite/tests/simplCore/should_compile/all.T
index ae48423fa0..a472aa05d9 100644
--- a/testsuite/tests/simplCore/should_compile/all.T
+++ b/testsuite/tests/simplCore/should_compile/all.T
@@ -478,3 +478,4 @@ test('RewriteHigherOrderPatterns', normal, compile, ['-O -ddump-rule-rewrites -d
test('T23024', normal, multimod_compile, ['T23024', '-O -v0'])
test('T23026', normal, compile, ['-O'])
test('T23267', [expect_broken(23267), only_ways(['ghci']), extra_hc_opts('-fno-unoptimized-core-for-interpreter -fspec-constr')], ghci_script, ['T23267.script'])
+test('T23362', normal, compile, ['-O'])