summaryrefslogtreecommitdiff
path: root/testsuite/tests/stranal/should_run/T21717b.hs
blob: ed614422156e557042c233f90f694d4828e44e39 (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 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