GHC panic when fiddling with quantified constraints
Summary
Given the following code:
{-# LANGUAGE
QuantifiedConstraints
, StandaloneKindSignatures
, TypeOperators
, GADTs
, ConstraintKinds
, RankNTypes
, UndecidableInstances
, ImpredicativeTypes
#-}
module Typelevel.Constraint.Repro where
import Data.Kind (Constraint, Type)
type Dict :: Constraint -> Type
data Dict c
where
Dict :: c => Dict c
type (⇒) :: Constraint -> Constraint -> Constraint
type c ⇒ d = c => d
infixr 0 ⇒
type (\/) :: Constraint -> Constraint -> Constraint
type a \/ b = (forall r. (a ⇒ r, b ⇒ r) ⇒ r)
infixr 5 \/
dict :: Dict ((x \/ y) \/ z ⇒ x \/ y \/ z)
dict = Dict
GHC will blow up with the following error message:
ghc: panic! (the 'impossible' happened)
(GHC version 8.10.4:
GHC.StgToCmm.Env: variable not found
irred_a1vk
local binds for:
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1179:37 in ghc:Outputable
pprPanic, called at compiler/GHC/StgToCmm/Env.hs:149:9 in ghc:GHC.StgToCmm.Env
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
Steps to reproduce
Compiling the module given above with GHC 8.10.4 should do it.
Expected behavior
GHC should not panic, and should either produce a type error or a successful compilation.
Environment
- GHC version used: 8.10.4