Skip to content

Assert failed: CanEqCanLHSFinish: (TyEq:N) not satisfied

Summary

A simple program used to compile with GHC 9.4.2, but fails with compiler panic in GHC 9.5.20221013.

Steps to reproduce

Save this as Lib.hs:

{-# LANGUAGE GADTs, ScopedTypeVariables #-}

module Lib where

import Data.Coerce
import Data.Kind

data Foo (ix :: Type) = Foo

data Some t where
  Some :: t ix -> Some t

newtype Identity a = Identity a

newtype Compose f g a = Compose (f (g a))

foo :: Some (Compose Identity Foo) -> Some (Compose Identity Foo)
foo = coerce (\(Some (x :: Compose Identity Foo k)) -> Some x)
$ ghc-9.4.2 Lib.hs
[1 of 1] Compiling Lib              ( Foo.hs, Foo.o )
$ ghc-20221013 Lib.hs
[1 of 1] Compiling Lib              ( Foo.hs, Foo.o )

<no location info>: error:
    panic! (the 'impossible' happened)
  GHC version 9.5.20221013:
	ASSERT failed!
  CanEqCanLHSFinish: (TyEq:N) not satisfied
  rhs: Compose Identity Foo
  Call stack:
      CallStack (from HasCallStack):
        assertPprM, called at compiler/GHC/Tc/Solver/Canonical.hs:2345:10 in ghc:GHC.Tc.Solver.Canonical

Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug

Expected behavior

I expect GHC 9.5.20221013 to compile the program successfully, or at least without a panic.

Environment

  • GHC version used: 9.5.20221013
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information