Skip to content

HEAD-only panic (isUnliftedType) with PatternSynonyms + OverloadedStrings

(Originally observed in a head.hackage CI job here.)

GHC HEAD (at commit bd0f4184) panics when building the what4-1.3 library on Hackage. Here is a minimized example:

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
module Bug where

import qualified Data.ByteString as BS

data Sort = MkSort BS.ByteString [()]

pattern Array :: () -> () -> Sort
pattern Array x y = MkSort "Array" [x,y]

This panics when compiled with optimization on HEAD:

$ ~/Software/ghc-9.5.20220918/bin/ghc -fforce-recomp Bug.hs -O
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )
WARNING:
  Simplifier bailing out
  Bug, after 4 iterations [58, 28, 31, 3]
    Size = {terms: 192, types: 120, coercions: 0, joins: 2/2}
  Call stack:
      CallStack (from HasCallStack):
        warnPprTrace, called at compiler/GHC/Core/Opt/Simplify.hs:192:9 in ghc:GHC.Core.Opt.Simplify

<no location info>: error:
    panic! (the 'impossible' happened)
  GHC version 9.5.20220918:
        isUnliftedType
  r_s1bI :: TYPE rep_s1bH
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/GHC/Utils/Panic.hs:188:37 in ghc:GHC.Utils.Panic
        pprPanic, called at compiler/GHC/Core/Type.hs:2483:7 in ghc:GHC.Core.Type
        isUnliftedType, called at compiler/GHC/Stg/InferTags/Rewrite.hs:220:15 in ghc:GHC.Stg.InferTags.Rewrite

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

But not with GHC 9.4 and earlier:

$ ghc-9.4.2 -fforce-recomp Bug.hs -O
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information