MCPcopy Create free account
hub / github.com/cel-expr/cel-go / AddLetVar

Method AddLetVar

repl/evaluator.go:612–623  ·  view source on GitHub ↗

AddLetVar adds a let variable to the evaluation context. The expression is planned but evaluated lazily.

(name string, expr string, typeHint *envlib.TypeDesc)

Source from the content-addressed store, hash-verified

610// AddLetVar adds a let variable to the evaluation context.
611// The expression is planned but evaluated lazily.
612func (e *Evaluator) AddLetVar(name string, expr string, typeHint *envlib.TypeDesc) error {
613 // copy the current context and attempt to update dependant expressions.
614 // if successful, swap the current context with the updated copy.
615 ctx := e.ctx.copy()
616 ctx.addLetVar(name, expr, typeHint)
617 err := updateContextPlans(ctx, e.env)
618 if err != nil {
619 return err
620 }
621 e.ctx = *ctx
622 return nil
623}
624
625// AddLetFn adds a let function to the evaluation context.
626func (e *Evaluator) AddLetFn(name string, params []letFunctionParam, resultType *envlib.TypeDesc, expr string) error {

Callers 15

TestEvalSingleLetVarFunction · 0.95
TestEvalMultiLetFunction · 0.95
TestEvalErrorFunction · 0.95
TestLetErrorFunction · 0.95
TestLetTypeHintErrorFunction · 0.95
TestDeclareErrorFunction · 0.95
TestDelErrorFunction · 0.95
TestAddLetFnFunction · 0.95
TestAddDeclFnFunction · 0.95
TestAddDeclFnErrorFunction · 0.95
TestDelLetFnFunction · 0.95

Calls 3

updateContextPlansFunction · 0.85
addLetVarMethod · 0.80
copyMethod · 0.45

Tested by 14

TestEvalSingleLetVarFunction · 0.76
TestEvalMultiLetFunction · 0.76
TestEvalErrorFunction · 0.76
TestLetErrorFunction · 0.76
TestLetTypeHintErrorFunction · 0.76
TestDeclareErrorFunction · 0.76
TestDelErrorFunction · 0.76
TestAddLetFnFunction · 0.76
TestAddDeclFnFunction · 0.76
TestAddDeclFnErrorFunction · 0.76
TestDelLetFnFunction · 0.76