Skip to content

Compiler panic with `generics-sop` and type applications (9.2 and HEAD)

Summary

The following program produces a compiler panic with GHC 9.2-alpha2 and HEAD, but not 9.0.1. Something about the Generic class from generics-sop seems to be causing this. Placing the type application in a let binding seems to be necessary for the panic to fire.

Steps to reproduce

This module produces a compiler panic:


{-# LANGUAGE TypeApplications, TypeFamilies, ScopedTypeVariables #-}
module Main where
import Generics.SOP -- from generics-sop  0.5.1.1 

repo :: forall a b. Generic a => a -> b
repo x =
    let y = undefined @a
    in undefined

It produces this message:

ghc: panic! (the 'impossible' happened)
  (GHC version 9.2.0.20210608:
        addTcEvBind CoEvBindsVar
  [G] irred_aaaG = $p1All @[*] @Top @(Code a_aaaq[sk:1]) $dAll_aaaF
  aaaz
  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/Tc/Utils/Monad.hs:1700:5 in ghc:GHC.Tc.Utils.Monad

Expected behaviour

The impossible shouldn't happen

Environment

I was able to reproduce with ghc from the following CI artefacts:

I wasn't able to reproduce this with the 9.0.1 release from downloads.haskell.org

Optional:

  • Operating System: Ubuntu-18.04 under WSl2
  • System Architecture: x86_64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information