From 6a1e0084f4dd688a27def68cef22d9137682b600 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 17 Feb 2025 22:58:36 +0800 Subject: [PATCH] ssa: support len([]func()) --- compiler/ssa/expr.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler/ssa/expr.go b/compiler/ssa/expr.go index 31214271..29a4dd75 100644 --- a/compiler/ssa/expr.go +++ b/compiler/ssa/expr.go @@ -1169,6 +1169,12 @@ func (b Builder) BuiltinCall(fn string, args ...Expr) (ret Expr) { ret.impl = b.InlineCall(b.Pkg.rtFunc("SliceAppend"), src, b.StringData(elem), b.StringLen(elem), b.Prog.Val(int(etSize))).impl return + default: + etSize := b.Prog.SizeOf(elem.Type) + ret.Type = src.Type + ret.impl = b.InlineCall(b.Pkg.rtFunc("SliceAppend"), + src, elem, b.Const(constant.MakeInt64(1), b.Prog.Int()), b.Prog.Val(int(etSize))).impl + return } } }