Update Hadrian
[ghc.git] / testsuite / tests / simplCore / should_compile / T3118.hs
1 -- Test Trac #3118
2
3 -- The test is quite delicate. It aims to get 'f' to look like
4 -- f y = case x of
5 -- Red -> (y, y)
6 -- _ -> let v = case x of
7 -- Green -> 2
8 -- Blue -> 3
9 -- in (v, 5)
10 --
11 -- And now float the inner case to top level
12 -- so that it's not so obvious that the Red case
13 -- cannot occur. This crashed GHC 6.10.
14 --
15 -- It's delicate to make the bug show up
16 -- (a) because it relies on not "seeing" that
17 -- x = Red until later.
18 -- (b) because dropping the Red case must happen
19 -- before float-out, which itself happens v early
20
21 -- In the original report, the x=Red was concealed by profiling
22
23 module T3118 where
24
25 data Colour = Red | Green | Blue
26
27
28 {-# NOINLINE [0] f #-}
29 g x = Red
30
31 x = g True
32
33 f :: Int -> (Int,Int)
34 f y = case x of
35 Red -> (y, y)
36 xx -> let v = case xx of
37 Red -> 1
38 Green -> 2
39 Blue -> 3
40 in (v, 5)