blob: 45551ffd2366a3f35926c16df38f8a84c4239607 (
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
28
29
30
31
32
33
34
35
36
37
38
39
|
-- This test exposes the bug in GHC 7.0.1 (and earlier)
-- which did the following rule rewrite:
--
-- f (let v = 2 in g v) (let v = 3 in g v)
-- ---> let v = 2 in let v = 3 in g v + g v
--
-- which is wrong because of the shadowing of v
module Main where
foo :: Int -> Int
{-# INLINE foo #-}
foo x = g (bar (x,x))
bar :: (Int,Int) -> Int
{-# NOINLINE bar #-}
bar (x,y) = x
baz :: Int -> Int
{-# NOINLINE baz #-}
baz x = x
f :: Int -> Int -> Int
{-# NOINLINE f #-}
f x y = x+y
g :: Int -> Int
{-# NOINLINE g #-}
g x = x
{-# RULES
"f/g" [1] forall x y. f (g x) (g y) = x + y
#-}
main = print $ f (foo (baz 1)) (foo (baz 2))
-- Should print 3
-- Bug means that it prints 4
|