[GHC] #15509: `showEFloat` inconsistency introduced in base-4.12

GHC ghc-devs at haskell.org
Sun Aug 12 11:44:21 UTC 2018


#15509: `showEFloat` inconsistency introduced in base-4.12
-------------------------------------+-------------------------------------
           Reporter:  hvr            |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.6.1
          Component:  Compiler       |           Version:
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 While base-4.11 had a `showEFloat` that behaved like

 {{{#!hs
 showEFloat (Just n) | n <= 0 == showEFloat (Just 1)
 }}}

 For non-positive values, base-4.12 introduced an unfortunate
 inconsistency:

 {{{#!hs
 showEFloat (Just n) | n < 0 == showEFloat (Just 1)
 -- NB: *not* equivalent to     showEFloat (Just 0)
 }}}

 e.g. now we have

 {{{#!hs
 showEFloat (Just 2)    1.0 "" == "1.00e0"
 showEFloat (Just 1)    1.0 "" == "1.0e0"
 showEFloat (Just 0)    1.0 "" == "1e0"
 showEFloat (Just (-1)) 1.0 "" == "1.0e0"
 showEFloat (Just (-2)) 1.0 "" == "1.0e0"
 }}}

 iow, negative `n`s in the precision argument are now treated differently
 from `(Just 0)` which is a source of subtle bugs for API consumers which
 assume `showEFloat` to have "continuous total" semantics for the precision
 argument.

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


More information about the ghc-tickets mailing list