[GHC] #7168: Loop

GHC cvs-ghc at haskell.org
Mon Aug 20 15:52:54 CEST 2012


#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>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the Glasgow-haskell-bugs mailing list