summaryrefslogtreecommitdiff
path: root/testsuite/tests/stranal/should_compile/T20746b.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2021-11-26 16:02:02 +0000
committerSimon Peyton Jones <simon.peytonjones@gmail.com>2022-01-04 15:13:00 +0000
commit3e1991841a4c6c59fa8a8f43eb7d8f26991338b1 (patch)
treead706ad22ce02fd296183bb81c642ab7dfa6819b /testsuite/tests/stranal/should_compile/T20746b.hs
parente571007a68414471486945bc10064dcd9535a199 (diff)
downloadhaskell-wip/T18993a.tar.gz
Improve boxity in deferAfterPreciseExceptionwip/T18993a
As #20746 showed, the demand analyser behaved badly in a key I/O library (`GHC.IO.Handle.Text`), by unnessarily boxing and reboxing. This patch adjusts the subtle function deferAfterPreciseException; it's quite easy, just a bit subtle. See the new Note [deferAfterPreciseException] And this MR deals only with Problem 2 in #20746. Problem 1 is still open.
Diffstat (limited to 'testsuite/tests/stranal/should_compile/T20746b.hs')
-rw-r--r--testsuite/tests/stranal/should_compile/T20746b.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/testsuite/tests/stranal/should_compile/T20746b.hs b/testsuite/tests/stranal/should_compile/T20746b.hs
new file mode 100644
index 0000000000..6804fb4449
--- /dev/null
+++ b/testsuite/tests/stranal/should_compile/T20746b.hs
@@ -0,0 +1,14 @@
+module T20746b where
+
+mightThrow :: Int -> IO Int
+{-# NOINLINE mightThrow #-}
+mightThrow n = return n
+
+-- Should not unbox trp
+-- Recursive because if it's too small
+-- we don't do worker/wrapper at all
+f :: Bool -> (Int, Int, Int) -> IO (Int, Int, Int)
+f False trp = f True trp
+f True trp@(a,b,c) = do
+ _ <- mightThrow a -- this potentially throwing IO action should not force unboxing of trp
+ return trp