Panic involving levity polymorphism
I have the following program, tested on GHC 8.10 and 9.1.20210217:
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Panic where
import GHC.Exts
class Call (r :: RuntimeRep) where
type Lev (a :: TYPE r)
lift' :: (a :: TYPE r) -> (Lev a -> b) -> b
mapF :: forall r' (a :: TYPE r) (b :: TYPE r'). Call r' => (a -> b) -> Lev a -> Lev b
instance Call LiftedRep where
type Lev a = a
lift' a k = k a
mapF f x = lift' (f x) id
On GHC 8.10, it produces the following output:
[1 of 1] Compiling Panic ( panic.hs, panic.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.10.2:
splitFunTy
()
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1179:37 in ghc:Outputable
pprPanic, called at compiler/types/Type.hs:1018:32 in ghc:Type
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
The error message is a bit more detailed with a semi-recent version of GHC 9.1:
[1 of 1] Compiling Main ( /home/zubin/unboxed.hs, /home/zubin/unboxed.o )
ghc: panic! (the 'impossible' happened)
(GHC version 9.1.20210217:
ASSERT failed!
()
id @(Lev b_a17Y)
HsApp lift' (f_ax3 x_ax4) id
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Utils/Panic.hs:300:5 in ghc:GHC.Utils.Panic
assertPprPanic, called at compiler/GHC/Core/Make.hs:170:49 in ghc:GHC.Core.Make
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug