summaryrefslogtreecommitdiff
path: root/testsuite/tests/stranal/sigs/T19407.hs
blob: af5eca86163de1386e076ff199d9b09ad1aa8d40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{-# OPTIONS_GHC -O2 -fforce-recomp #-}

-- | The gist here: `f` is strict in `t::T` and its field `h::Huge`, but mustn't unbox it.
-- Otherwise, `$wf` has to rebox it for the call to `$wg` (which is lazy in `t`) and that
-- also means reconstructing `h`, although most fields are absent anyway.
--
-- Solution: `g` is lazy in `t` and we can't unbox it. Thus, its signature
-- shouldn't say which parts of `t` are absent!
module T19407 where

data Huge = Huge Bool () () () () () () () () () () () () () () () () () () () () ()
data T = T { h :: Huge, n :: Int }

f :: T -> Int -- like warnAboutOverflowedLit
f t = g (h t) t
{-# NOINLINE f #-}

g :: Huge -> T -> Int -- like warnAboutOverflowedLiterals
g (Huge b _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) t =
  if b then 0 else n t
{-# NOINLINE g #-}