summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-04-27 17:24:45 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-30 16:55:32 -0400
commitee891c1e25028ca4fb73e89a59b6538b516deae8 (patch)
treeab1370d77548a77e8892aac68c69eac0633003fc
parent34b2820018ee05336be061aabea7d421bdd49ab9 (diff)
downloadhaskell-ee891c1e25028ca4fb73e89a59b6538b516deae8.tar.gz
Add test for T21229
-rw-r--r--testsuite/tests/simplCore/should_run/T21229.hs24
-rw-r--r--testsuite/tests/simplCore/should_run/T21229.stdout1
-rw-r--r--testsuite/tests/simplCore/should_run/all.T1
3 files changed, 26 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_run/T21229.hs b/testsuite/tests/simplCore/should_run/T21229.hs
new file mode 100644
index 0000000000..c5e22f6773
--- /dev/null
+++ b/testsuite/tests/simplCore/should_run/T21229.hs
@@ -0,0 +1,24 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeApplications #-}
+{-# LANGUAGE AllowAmbiguousTypes #-}
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE KindSignatures #-}
+module Main where
+
+data B = T | F deriving Show
+
+class Sing (b :: B) where sing :: B
+instance Sing 'T where sing = T
+instance Sing 'F where sing = F
+
+f :: forall a. Sing a => Int -> (Int -> B -> B) -> B
+f 0 g = g 0 (sing @a)
+f n g = f @a (n-1) g
+
+h :: forall a. Sing a => Int -> (Int -> B -> B) -> B
+h = case sing @a of
+ T -> f @'T
+ F -> f @a
+{-# NOINLINE h #-}
+
+main = print $ h @'T 0 (\ _ a -> a)
diff --git a/testsuite/tests/simplCore/should_run/T21229.stdout b/testsuite/tests/simplCore/should_run/T21229.stdout
new file mode 100644
index 0000000000..62a6e3c9df
--- /dev/null
+++ b/testsuite/tests/simplCore/should_run/T21229.stdout
@@ -0,0 +1 @@
+T
diff --git a/testsuite/tests/simplCore/should_run/all.T b/testsuite/tests/simplCore/should_run/all.T
index 54ec5b8bff..34e7e2e386 100644
--- a/testsuite/tests/simplCore/should_run/all.T
+++ b/testsuite/tests/simplCore/should_run/all.T
@@ -101,3 +101,4 @@ test('T19569', [only_ways(['optasm']),extra_run_opts('True 1000000')], compile_a
test('T20203', normal, compile, ['-O -dsuppress-all -dsuppress-uniques -dno-typeable-binds -ddump-simpl'])
test('T19313', normal, compile_and_run, [''])
test('UnliftedArgRule', normal, compile_and_run, [''])
+test('T21229', normal, compile_and_run, ['-O'])