Skip to content

panic: No skolem info when trying to use variable with polymorphic kind as Type/Constraint

Summary

In a quantified constraint in the context for an instance declaration, when trying to use a type variable with a polymorphic kind as either a Type or a Constraint, ghc will panic.

Steps to reproduce

Each of the following three instances trigger the error

{-# LANGUAGE ExplicitForAll , PolyKinds #-}

instance (forall (a :: k) . a) => Show b
instance (forall (a :: k) . Show a) => Show b
instance (forall (a :: k) . a -> a) => Show b

Error:

ghc: panic! (the 'impossible' happened)
  (GHC version 9.0.0.20201227:
        No skolem info:
  [k_aEZ[sk:1]]
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/GHC/Utils/Outputable.hs:1230:37 in ghc:GHC.Utils.Outputable
        pprPanic, called at compiler/GHC/Tc/Errors.hs:2810:17 in ghc:GHC.Tc.Errors

Expected behavior

8.10 has the expected behavior: show the following type error

Bug.hs:3:29: error:
    • Expected a constraint, but ‘a’ has kind ‘k’
    • In the instance declaration for ‘Show b’
  |
3 | instance (forall (a :: k) . a) => Show b
  |                             ^

Bug.hs:4:34: error:
    • Expected a type, but ‘a’ has kind ‘k’
    • In the first argument of ‘Show’, namely ‘a’
      In the instance declaration for ‘Show b’
  |
4 | instance (forall (a :: k) . Show a) => Show b
  |                                  ^

Bug.hs:5:29: error:
    • Expected a constraint, but ‘a -> a’ has kind ‘*’
    • In the instance declaration for ‘Show b’
  |
5 | instance (forall (a :: k) . a -> a) => Show b
  |                             ^^^^^^
Failed, no modules loaded.

Environment

  • GHC version used: 9.0.0.20201227

Optional:

  • Operating System: Ubuntu inside WSL2 inside Windows 10
  • System Architecture: x86_64
Edited by Jakob Brünker
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information