Skip to content

mkCoCast panic in 9.2

The following file causes a panic in 9.2.1 and on the ghc-9.2 branch

{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
module M where

type family Item l
type instance Item [a] = a

f :: Enum (Item l) => l
f = f

x = (_ f) :: Int
  (GHC version 9.2.0.20220224:
	mkCoCast
  (Enum (Sym (D:R:Item[][0] <Char>_N)))_R
  Enum Char ~ Enum (Item [Char])
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
        pprPanic, called at compiler/GHC/Core/Coercion.hs:1675:5 in ghc:GHC.Core.Coercion

HEAD is good:

M.hs:10:6: error:
    • Found hole: _ :: t0 -> Int
      Where: ‘t0’ is an ambiguous type variable

I haven't checked which commit fixed it. There are no other tickets mentioning mkCoCast, so I think it's worth checking if the bug is actually fixed or merely hidden.

Credits to Dominic Steinitz for the initial report.

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