20 Aug 2012 15:52
#7168: Loop
GHC <cvs-ghc <at> haskell.org>
2012-08-20 13:52:54 GMT
2012-08-20 13:52:54 GMT
#7168: Loop
-----------------------------------------+----------------------------------
Reporter: bas | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 7.4.1 | Keywords: Lazy evaluation, Loop, Eagerness
Os: Unknown/Multiple | Architecture: x86
Failure: Incorrect result at runtime | Testcase:
Blockedby: | Blocking:
Related: |
-----------------------------------------+----------------------------------
When patternmatching on (a,b), the variables a and b are sometimes
evaluated eagerly, though they should not be. To see where this occurs,
please try to evaluate f :
{{{
f = (1,error "this will not be evaluated!") .++. carefully f
(a,b) .++. (c,d) = (a+c,0)
carefully (a,b) = (1, a + b)
}}}
Note that the expected result here is (2,0). My workaround: the program
works correctly if the last line is replaced by:
{{{
carefully x = (1, fst x + snd x)
}}}
--
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7168>
(Continue reading)
RSS Feed