diff options
author | David Terei <davidterei@gmail.com> | 2011-07-20 11:09:03 -0700 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2011-07-20 11:26:35 -0700 |
commit | 16514f272fb42af6e9c7674a9bd6c9dce369231f (patch) | |
tree | e4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/simplCore/should_run/T4814.hs | |
parent | ebd422aed41048476aa61dd4c520d43becd78682 (diff) | |
download | haskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz |
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/simplCore/should_run/T4814.hs')
-rw-r--r-- | testsuite/tests/simplCore/should_run/T4814.hs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_run/T4814.hs b/testsuite/tests/simplCore/should_run/T4814.hs new file mode 100644 index 0000000000..45551ffd23 --- /dev/null +++ b/testsuite/tests/simplCore/should_run/T4814.hs @@ -0,0 +1,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 + |