summaryrefslogtreecommitdiff
path: root/testsuite/tests/stranal/should_run/T21717b.hs
blob: 80b3ed00399da6decc62583348d9ab33ab1da8e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import System.Environment
import GHC.Exts

g :: (Int -> (Int, Int)) -> Int
-- Should *not* infer strictness SC(S,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