Skip to content

GHC falls into a hole if given incorrect kind signature

If one provides an incorrect kind signature GHC throws up. For instance, this non-sense,

{-# LANGUAGE RankNTypes, PolyKinds, TypeInType, GADTs, UndecidableSuperClasses #-}

module Play where

import GHC.Types hiding (TyCon)

data TypeRep (a :: k)

class Typeable k => Typeable (a :: k) where
    typeRep :: TypeRep a

data Compose (f :: k1 -> *) (g :: k2 -> k1) (a :: k2) = Compose (f (g a))

-- Note how the kind signature on g is incorrect
instance (Typeable f, Typeable (g :: k), Typeable k) => Typeable (Compose f g) where
    typeRep = undefined

fails with

λ> :load Bug.hs
[1 of 1] Compiling Play             ( Bug.hs, interpreted )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.1.20160122 for x86_64-unknown-linux):
	fvProv falls into a hole {abet}

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
Edited by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information