Skip to content

Panic in pprMatch when "deriving Foldable" is used with -ddump-tc-trace

Summary

Trying to compile the following program in current HEAD with -ddump-tc-trace flag results in a panic:

{-# LANGUAGE DeriveFoldable #-}
module Test where

data T a = MkT a
  deriving Foldable
rndghc: panic! (the 'impossible' happened)
  GHC version 9.3.20211004:
	pprMatch

CaseAlt
[f, (MkT a1)]
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/Hs/Expr.hs:1364:29 in ghc:GHC.Hs.Expr

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

I know that this issue is already present in 6141aef4, but I didn't check any further. 8.10.7 doesn't have this issue as far as I'm aware.

Steps to reproduce

Run ghc -ddump-tc-trace Test.hs on the program above.

Expected behavior

No panic :)

Environment

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