Assertion failure with bad levity polymorphism
The following program causes an assertion failure:
module M where
import GHC.Exts
f = f :: (_ :: TYPE r)
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.7.20230606:
ASSERT failed!
2
1
w_aja[tau:1]
w_ajn[tau:0]
w_ajn[tau:0]
Call stack:
CallStack (from HasCallStack):
massertPpr, called at compiler/GHC/Tc/Zonk/TcType.hs:159:10 in ghc-9.7-inplace:GHC.Tc.Zonk.TcType
writeMetaTyVarRef, called at compiler/GHC/Tc/Zonk/TcType.hs:115:5 in ghc-9.7-inplace:GHC.Tc.Zonk.TcType
writeMetaTyVar, called at compiler/GHC/Tc/Utils/TcMType.hs:2295:22 in ghc-9.7-inplace:GHC.Tc.Utils.TcMType
promoteMetaTyVarTo, called at compiler/GHC/Tc/Utils/TcMType.hs:2305:25 in ghc-9.7-inplace:GHC.Tc.Utils.TcMType
promoteTyVarSet, called at compiler/GHC/Tc/Solver.hs:1906:15 in ghc-9.7-inplace:GHC.Tc.Solver
CallStack (from HasCallStack):
panic, called at compiler/GHC/Utils/Error.hs:479:29 in ghc-9.7-inplace:GHC.Utils.Error
If assertions are disabled, it is correctly rejected.
Likely related to #23051.