[GHC] #15696: Derived Ord instance for enumerations with more than 8 elements seems to be incorrect

GHC ghc-devs at haskell.org
Fri Oct 5 14:32:24 UTC 2018


#15696: Derived Ord instance for enumerations with more than 8 elements seems to be
incorrect
-------------------------------------+-------------------------------------
        Reporter:  mrkkrp            |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  highest           |            Milestone:  8.6.2
       Component:  Compiler          |              Version:  8.6.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Incorrect result  |  Unknown/Multiple
  at runtime                         |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D5196,
       Wiki Page:                    |  Phab:D5201
-------------------------------------+-------------------------------------

Comment (by simonpj):

 > In compile time we sometimes know that the argument is definitely some
 constructor C

 The simplifier does optimise this:
 {{{
 data T = T1 | T2 | T3 | T4 Char

 boo = T4 'x'

 f x = case x of
        T1 -> getTag x
        T2 -> getTag boo
        _  -> getTag x
 }}}
 produces `-ddump-simpl`
 {{{
 f :: T -> GHC.Prim.Int#
 f = \ (x_aXJ :: T) ->
       case x_aXJ of wild_Xf {
         __DEFAULT -> GHC.Prim.dataToTag# @ T wild_Xf;
         T1 -> 0#;
         T2 -> 3#
       }
 }}}

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


More information about the ghc-tickets mailing list