#5279: numericEnumFromThen breaks standard behaviour in presence of ⊥
---------------------------------+------------------------------------------
    Reporter:  ehird             |       Owner:                             
        Type:  bug               |      Status:  new                        
    Priority:  normal            |   Component:  Compiler                   
     Version:  7.0.3             |    Keywords:                             
    Testcase:                    |   Blockedby:                             
          Os:  Unknown/Multiple  |    Blocking:                             
Architecture:  Unknown/Multiple  |     Failure:  Incorrect result at runtime
---------------------------------+------------------------------------------
 Haskell 2010 (and, for what it's worth, 98) require the following
 behaviour for `numericEnumFromThen`:

 {{{
 numericEnumFromThen n m =  iterate (+(m-n)) n
 }}}

 but GHC has:

 {{{
 numericEnumFromThen n m = n `seq` m `seq` (n : numericEnumFromThen m
 (m+m-n))
 }}}

 The standard evaluation of `numericEnumFromThen 0.0 undefined` is
 equivalent to `0.0 : repeat undefined`, but GHC evaluates it as
 `undefined`:

 {{{
 > Prelude> [0.0, undefined..]
 *** Exception: Prelude.undefined
 }}}

 So unfortunately, this optimisation changes semantics in violation of the
 Report.

 `numericEnumFrom` also suffers from this issue; the evaluation of
 `numericEnumFrom undefined` should be equivalent to `repeat undefined`,
 but GHC evaluates it as `undefined`. This is a more minor issue, however.
 :)

 (Tested with 7.0.3 and whatever version lambdabot uses on freenode.)

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5279>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to