[GHC] #8952: Bang patterns don't work as the specification says

GHC ghc-devs at haskell.org
Thu Apr 3 03:09:04 UTC 2014


#8952: Bang patterns don't work as the specification says
--------------------------+------------------------------------------------
       Reporter:  dolio   |             Owner:
           Type:  bug     |            Status:  new
       Priority:  normal  |         Milestone:
      Component:          |           Version:  7.6.3
  Compiler                |  Operating System:  Unknown/Multiple
       Keywords:          |   Type of failure:  Incorrect result at runtime
   Architecture:          |         Test Case:
  Unknown/Multiple        |          Blocking:
     Difficulty:          |
  Unknown                 |
     Blocked By:          |
Related Tickets:          |
--------------------------+------------------------------------------------
 In investigating the behavior of bang patterns for an implementation of my
 own, I came across a discrepancy between the specification and GHC's
 implementation. Here is an example:

 {{{
 case Nothing of
   !(~(Just x)) -> 5
   Nothing      -> 12
 }}}

 This evaluates to 12. In other words, !(~p) is equivalent to p. However,
 the bang patterns description says that this should be equivalent to:

 {{{
 Nothing `seq` case Nothing of
   ~(Just x) -> 5
   Nothing   -> 12
 }}}

 which evaluates to 5. So, one of either the description or the
 implementation must be incorrect. In fact, GHC is even a bit confused, as
 it issues a warning about overlapping patterns for the bang pattern case
 statement, even though the successful branch is the 'unreachable' one.

 The description makes more sense to me, but I'm not terribly invested in
 the behavior of this; it is admittedly a pretty obscure corner case.

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


More information about the ghc-tickets mailing list