Skip to content

Backpack accepts ill-kinded instantiations. Can cause GHC panic

Given the following:

{-# language KindSignatures #-}
signature A where

data A :: *
module Foo where

import A

foo :: A -> A
foo = id
module IllKindedA where

type A = Maybe

GHC allows the signature A to be instantiated with IllKindedA:

mixins: foo (Foo as Bug) requires (A as IllKindedA)

Using the resulting module can cause odd errors or a panic. E.g. the following causes a panic:

module Bar where

import Bug

bar = foo
ghc: panic! (the 'impossible' happened)
  (GHC version 8.6.2 for x86_64-unknown-linux):
	getRuntimeRep
  A :: * -> *
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
        pprPanic, called at compiler/types/Type.hs:2049:18 in ghc:Type
Edited by aaronvargo
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information