Skip to content

diagrams-core-1.5.0 fails to compile on HEAD (expectJust isRecDataCon:go_tc_app)

Originally observed on a head.hackage CI job here.

diagrams-core-1.5.0 will panic if you compile it with GHC 9.3.20211020. Here is a heavily minimized example:

module Diagrams.Core.Types where

newtype Measured a = Measured { unmeasure :: () -> a }
data Subdiagram = Subdiagram () (Measured ())

mkSubdiagram :: () -> Subdiagram
mkSubdiagram d = Subdiagram d (Measured (\_ -> ()))
$ ~/Software/ghc-9.3.20211020/bin/ghc -fforce-recomp Bug.hs -O1
[1 of 1] Compiling Diagrams.Core.Types ( Bug.hs, Bug.o )

<no location info>: error:
    expectJust isRecDataCon:go_tc_app
CallStack (from HasCallStack):
  error, called at compiler/GHC/Data/Maybe.hs:68:27 in ghc:GHC.Data.Maybe
  expectJust, called at compiler/GHC/Core/Opt/WorkWrap/Utils.hs:1392:25 in ghc:GHC.Core.Opt.WorkWrap.Utils

Note that:

  • This is a regression from GHC 9.0.1 and 9.2.1-rc1, which do not panic.
  • -O1 or higher is required to trigger the bug.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information