Skip to content

GHC 8.8 (or later)-only panic (metaTyVarRef)

The following code panics on GHC 8.8 or later:

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

import Data.Proxy

class C f where
  m :: f (p :: Proxy a)
$ ~/Software/ghc5/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.20190330 for x86_64-unknown-linux):
        metaTyVarRef
  f_avi
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1169:37 in ghc:Outputable
        pprPanic, called at compiler/typecheck/TcType.hs:1215:14 in ghc:TcType

On GHC 8.6.4, this simply produces an error message:

$ /opt/ghc/8.6.4/bin/ghc Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

Bug.hs:8:8: error:
    • Expected kind ‘Proxy a -> *’, but ‘f’ has kind ‘k0’
    • In the type signature: m :: f (p :: Proxy a)
      In the class declaration for ‘C’
  |
8 |   m :: f (p :: Proxy a)
  |        ^^^^^^^^^^^^^^^^
Edited by Ryan Scott
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information