Skip to content

Seemingly reasonable levity-polymorphic binding crashes code generator

Consider this program:

module Hi where    
     
import GHC.Exts    
     
foo :: forall (lev :: Levity) (a :: TYPE (BoxedRep lev)). Addr# -> (# a #)    
foo x = addrToAny# x     

As of 112e4f9c this crashes the code generator:

$ _build/stage1/bin/ghc hi.hs -XMagicHash -XUnboxedTuples -XRankNTypes -XKindSignatures -XPolyKinds -XDataKinds
[1 of 1] Compiling Hi               ( hi.hs, hi.o )

<no location info>: error:
    panic! (the 'impossible' happened)
  GHC version 9.5.20220906:
        boxedRepDataCon
  [lev_ayH]
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/GHC/Utils/Panic.hs:188:37 in ghc:GHC.Utils.Panic
        pprPanic, called at compiler/GHC/Builtin/Types.hs:1628:9 in ghc:GHC.Builtin.Types

Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug

Noticed while implementing #20155 in !6245 (closed) .

Edited by sheaf
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information