Skip to content

Panic on malformed newtype

The following causes a panic on GHC 9.6.1:

data A = A !B
newtype B = B C C
data C = C A

Result:

<no location info>: error:
    panic! (the 'impossible' happened)
  GHC version 9.6.1:
        mkNewTyConRhs
  B [C, C]
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/GHC/Utils/Panic.hs:189:37 in ghc:GHC.Utils.Panic
        pprPanic, called at compiler/GHC/Tc/TyCl/Build.hs:70:27 in ghc:GHC.Tc.TyCl.Build
  CallStack (from HasCallStack):
    panic, called at compiler/GHC/Utils/Error.hs:454:29 in ghc:GHC.Utils.Error

GHC versions 9.4.5 and 9.2.5 do not panic and report the error correctly. I haven't tested other versions.

This is similar to #15523 (closed).

Edited by Pedro Minicz
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information