Skip to content

GHC panic (expectJust tcSplitFunTy)

The following program crashes GHC:

{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
module Bug where

import Data.Kind

type DComp a (b :: a ~> Type) (c :: forall (x :: a). b x ~> Type)
           (f :: forall (x :: a). forall (y :: b x) -> c y)
           (g :: forall (x :: a) -> b x)
           (x :: a)
         = f (g x)
$ ~/Software/ghc-kcsongor/inplace/bin/ghc-stage2 Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 8.9.20190408 for x86_64-unknown-linux):
        expectJust tcSplitFunTy
CallStack (from HasCallStack):
  error, called at compiler/utils/Maybes.hs:56:27 in ghc:Maybes
  expectJust, called at compiler/typecheck/TcType.hs:1525:20 in ghc:TcType