Skip to content

Pattern synonym panic!

Summary

Using Constraints in kinds, representation polymorphism, and patternSynonyms results in a panic!

ghc.exe: panic! (the 'impossible' happened)
  (GHC version 9.0.1:
	tcInvisibleTyBinder
  ctxt_a1P6[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\\Utils\\Instantiate.hs:419:5 in ghc:GHC.Tc.Utils.Instantiate

Steps to reproduce

compile this


{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ConstraintKinds #-}

import GHC.Exts
import GHC.Types
import Data.Kind (Type,FUN)

pattern ID :: forall bb (u::RuntimeRep) b ctxt (f::FUN Many RuntimeRep (FUN Many RuntimeRep Type)). (b :: (ctxt)=>f u bb)
pattern ID <- (a :: f u bb)

Expected behavior

give an error message or don't fail

Environment

GHC 9.0.1

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