Assertion failure in demand analyser with levity polymorphic code
Steps to reproduce
Compile the following code with -O
(extracted from the unboxed library)
{-# Language DataKinds #-}
{-# Language NoImplicitPrelude #-}
{-# Language RebindableSyntax #-}
module Def.Int where
import GHC.Types
import qualified Prelude
class Eq (a :: TYPE r) where
(==) :: a -> a -> Bool
class Num (a :: TYPE r) where
fromInteger :: Prelude.Integer -> a
roundDef :: forall (a :: TYPE IntRep) . (Eq a, Num a) => a -> ()
roundDef 0 = ()
This results in
ghc: panic! (the 'impossible' happened)
GHC version 9.3.20210519:
ASSERT failed!
($dNum_aDR
`cast` (N:Num[0] <'IntRep>_N <a_aDP>_N
:: Num a_aDP ~R# (Integer -> a_aDP)))
lvl_sEX
Call stack:
CallStack (from HasCallStack):
assertPpr, called at compiler/GHC/Core/Opt/DmdAnal.hs:345:5 in ghc:GHC.Core.Opt.DmdAnal
dmdAnalStar, called at compiler/GHC/Core/Opt/DmdAnal.hs:391:29 in ghc:GHC.Core.Opt.DmdAnal
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
Environment
- GHC version used: HEAD (9.3.20210519)