ASSERT failed! OPAQUE fun with boxity
Summary
Observed in CI for !9359, the following test program produces an assertion failure when compiled at -O
:
{-# LANGUAGE MagicHash #-}
module M where
import GHC.Exts
import GHC.IO
data T a = MkT !Bool !a
fun :: T a -> IO a
{-# OPAQUE fun #-}
fun (MkT _ x) = IO $ \s -> noinline seq# x s
-- evaluate/seq# should not produce its own eval for x
-- since it is properly tagged (from a strict field)
-- uses noinline to prevent caseRules from eliding the seq# in Core
The full error message is this:
Compile failed (exit code 1) errors were:
ghc-9.5.20221117: panic! (the 'impossible' happened)
GHC version 9.5.20221117:
ASSERT failed!
OPAQUE fun with boxity
fun
<1!P(A,L)><L>
(\ (@a_aBP)
(ds_dCh [Dmd=S!P(A,L)] :: T a_aBP)
(eta_B0 [OS=OneShot] :: State# RealWorld) ->
case ds_dCh of { MkT ds_dCl [Dmd=A] x_azg ->
noinline
@(forall a d. a -> State# d -> (# State# d, a #))
seq#
@a_aBP
@RealWorld
x_azg
eta_B0
})
`cast` (forall (a :: <*>_N).
<T (a |> <*>_N)>_R %<'Many>_N ->_R Sym (N:IO[0] <(a |> <*>_N)>_R)
:: (forall {a}.
T (a |> <*>_N)
-> State# RealWorld -> (# State# RealWorld, (a |> <*>_N) #))
~R# (forall {a}. T (a |> <*>_N) -> IO (a |> <*>_N)))
Call stack:
CallStack (from HasCallStack):
assertPpr, called at compiler/GHC/Core/Opt/WorkWrap.hs:582:5 in ghc:GHC.Core.Opt.WorkWrap
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
As the failure mode appears completely unrelated to that MR, I've posted it here.