summaryrefslogtreecommitdiff
path: root/testsuite/tests/stranal/should_run/T21717b.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/stranal/should_run/T21717b.hs')
-rw-r--r--testsuite/tests/stranal/should_run/T21717b.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/testsuite/tests/stranal/should_run/T21717b.hs b/testsuite/tests/stranal/should_run/T21717b.hs
new file mode 100644
index 0000000000..ed61442215
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/T21717b.hs
@@ -0,0 +1,19 @@
+import System.Environment
+import GHC.Exts
+
+g :: (Int -> (Int, Int)) -> Int
+-- Should *not* infer strictness SCS(P(SL,SL)) for h
+-- Otherwise `main` could use CbV on the error exprs below
+g h = fst (h 0) + snd (h 1)
+{-# NOINLINE g #-}
+
+main = do
+ m <- length <$> getArgs
+ -- The point here is that we print "1".
+ -- That means we may *not* use CbV/let-to-case on err!
+ -- GHC.Exts.lazy so that we don't lambda lift and float out the
+ -- obviously bottoming RHS (where it is no longer used strictly).
+ let err = GHC.Exts.lazy $ error (show m)
+ let f n | even n = (n+m, err)
+ | otherwise = (err, n+m)
+ print $! g f