summaryrefslogtreecommitdiff
path: root/testsuite/tests/arityanal/should_run/T21694a.hs
blob: ca01c1cb92ab0ca51287503d3019f9583392adcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Main (main) where

import GHC.Exts
import Control.DeepSeq
import System.Exit

-- If we eta expand the `False` branch will return
-- a lambda \eta -> z instead of z.
-- This behaves differently if the z argument is a bottom.
-- We used to assume that a oneshot annotation would mean
-- we could eta-expand on *all* branches. But this is clearly
-- not sound in this case. So we test for this here.
{-# NOINLINE f #-}
f :: Bool -> (Int -> Int) -> Int -> Int
f b z =
    case b of
        True -> oneShot $ \n -> n + 1
        False -> z



main :: IO Int
main = do
    return $! force $! f False (error "Urkh! But expected!")
    return 0