In-scope assertion failure with unpacking + existential
Compiling ghc -O M
causes an assertion failure in master (when assertions are enabled).
{-# LANGUAGE GADTs #-}
module A where
data Term where
BinaryTerm :: (Show tag) => {-# UNPACK #-} !Bool -> !tag -> Term
f :: Term -> String
f (BinaryTerm _ tag) = show tag
GHC version 9.9.20240217:
ASSERT failed!
in_scope InScope {}
tenv [X0 :-> tag_aEr]
tenvFVs {tag_aEr}
cenv []
cenvFVs {}
tys [(# (# #) | (# #) #)]
cos []
Call stack:
CallStack (from HasCallStack):
assertPpr, called at compiler/GHC/Core/TyCo/Subst.hs:686:5 in ghc-9.9-inplace:GHC.Core.TyCo.Subst
checkValidSubst, called at compiler/GHC/Core/TyCo/Subst.hs:718:29 in ghc-9.9-inplace:GHC.Core.TyCo.Subst
substTy, called at compiler/GHC/Types/Id/Make.hs:1407:59 in ghc-9.9-inplace:GHC.Types.Id.Make
CallStack (from HasCallStack):
panic, called at compiler/GHC/Utils/Error.hs:507:29 in ghc-9.9-inplace:GHC.Utils.Error
Reproduced using commit a7569495. I found it when investigating #24463 (closed) but it should be independent.