Skip to content

Panic with QuantifiedConstraints + RequiredTypeArguments

This code causes a panic in master:

{-# LANGUAGE QuantifiedConstraints, RequiredTypeArguments #-}
module T where

f :: (forall a -> Eq a) => a
f = f
<no location info>: error:
    panic! (the 'impossible' happened)
  GHC version 9.9.20231110:
	instDFunTypes
  df_aIu
  [Just a_aIB[sk:2]]
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/GHC/Utils/Panic.hs:186:37 in ghc-9.9-inplace:GHC.Utils.Panic
        pprPanic, called at compiler/GHC/Tc/Utils/Instantiate.hs:371:16 in ghc-9.9-inplace:GHC.Tc.Utils.Instantiate
  CallStack (from HasCallStack):
    panic, called at compiler/GHC/Utils/Error.hs:511:29 in ghc-9.9-inplace:GHC.Utils.Error

I think we should enforce that forall a -> ... is always used with TYPE rep. For forall a. ..., the body can also be a constraint; the situation is more complicated and covered by #22063. Finally, we accept forall {a}. Eq a which seems to give the same result as forall a. Eq a, presumably we should reject it.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information