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

Method AddDeclVar

repl/evaluator.go:641–650  ·  view source on GitHub ↗

AddDeclVar declares a variable in the environment but doesn't register an expr with it. This allows planning to succeed, but with no value for the variable at runtime.

(name string, typeHint *envlib.TypeDesc)

Source from the content-addressed store, hash-verified

639// AddDeclVar declares a variable in the environment but doesn't register an expr with it.
640// This allows planning to succeed, but with no value for the variable at runtime.
641func (e *Evaluator) AddDeclVar(name string, typeHint *envlib.TypeDesc) error {
642 ctx := e.ctx.copy()
643 ctx.addLetVar(name, "", typeHint)
644 err := updateContextPlans(ctx, e.env)
645 if err != nil {
646 return err
647 }
648 e.ctx = *ctx
649 return nil
650}
651
652// AddDeclFn declares a function in the environment but doesn't register an expr with it.
653// This allows planning to succeed, but with no value for the function at runtime.

Callers 2

TestDeclareErrorFunction · 0.95
ProcessMethod · 0.95

Calls 3

updateContextPlansFunction · 0.85
addLetVarMethod · 0.80
copyMethod · 0.45

Tested by 1

TestDeclareErrorFunction · 0.76