From 468a4bca6c5e65315af488326084e44e0a5794ca Mon Sep 17 00:00:00 2001 From: G Date: Tue, 5 May 2026 18:57:28 -0400 Subject: [PATCH] messagix/bloks: support bk.action.core.Let --- pkg/messagix/bloks/interp.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/messagix/bloks/interp.go b/pkg/messagix/bloks/interp.go index ab8e97c..bb52016 100644 --- a/pkg/messagix/bloks/interp.go +++ b/pkg/messagix/bloks/interp.go @@ -368,6 +368,23 @@ func (i *Interpreter) Evaluate(ctx context.Context, form *BloksScriptNode) (*Blo return first, nil } return i.Evaluate(ctx, &call.Args[1]) + case "bk.action.core.Let": + // Lazy-init: return arg0 if non-null, else apply the FuncConst in arg1. + current, err := i.Evaluate(ctx, &call.Args[0]) + if err != nil { + return nil, err + } + if current.IsTruthy() { + return current, nil + } + init, err := evalAs[*BloksLambda](ctx, i, &call.Args[1], "let.init") + if err != nil { + return nil, err + } + newArgs := make([]*BloksScriptLiteral, maxInterpArgs) + copy(newArgs, init.BoundArgs) + ctx = context.WithValue(ctx, interpCtxArgs, newArgs) + return i.Evaluate(ctx, init.Body) case "bk.action.bloks.GetVariable2", "bk.action.bloks.GetVariableWithScope": // The second argument to the WithScope variant is an integer that may specify // whether to get a local or global variable. For now, ignore.