Merge pull request #1210 from visualfc/ssa_typeassert

ssa: fix TypeAssert check null
This commit is contained in:
xushiwei
2025-08-08 19:48:27 +08:00
committed by GitHub
5 changed files with 409 additions and 318 deletions

View File

@@ -241,11 +241,10 @@ func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) Expr {
}
tx := b.faceAbiType(x)
tabi := b.abiType(assertedTyp.raw.Type)
var eq Expr
var val func() Expr
if x.RawType() == assertedTyp.RawType() {
eq = b.Const(constant.MakeBool(true), b.Prog.Bool())
eq = b.Const(constant.MakeBool(!b.faceData(x.impl).IsNull()), b.Prog.Bool())
val = func() Expr { return x }
} else {
if rawIntf, ok := assertedTyp.raw.Type.Underlying().(*types.Interface); ok {