[GHC] #1482: unsafeCoerce# doesn't always fully coerce

GHC trac at galois.com
Fri Aug 17 20:36:43 EDT 2007


#1482: unsafeCoerce# doesn't always fully coerce
----------------------------------------+-----------------------------------
    Reporter:  yeoh at cs.wisc.edu         |        Owner:         
        Type:  bug                      |       Status:  closed 
    Priority:  normal                   |    Milestone:         
   Component:  Compiler (Type checker)  |      Version:  6.6.1  
    Severity:  normal                   |   Resolution:  invalid
    Keywords:  unsafeCoerce#            |   Difficulty:  Unknown
          Os:  Linux                    |     Testcase:         
Architecture:  x86                      |  
----------------------------------------+-----------------------------------
Changes (by igloo):

  * resolution:  => invalid
  * status:  new => closed

Comment:

 Defaulting only happens in H98 if you have a Num constraint. If you use
 `-fextended-default-rules` then the original example works:
 {{{
 {-# OPTIONS_GHC -fglasgow-exts -fextended-default-rules #-}

 import GHC.Prim( unsafeCoerce# )

 e1 = unsafeCoerce# (+)
 e2 = unsafeCoerce# shows
 }}}
 Alternatively (and the preferred option), you can give shows an explicit
 type, so no defaulting needs to happen:
 {{{
 {-# OPTIONS_GHC -fglasgow-exts #-}

 import GHC.Prim( unsafeCoerce# )

 e1 = unsafeCoerce# (+)
 e2 = unsafeCoerce# (shows :: () -> ShowS)
 }}}

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


More information about the Glasgow-haskell-bugs mailing list