expressions now support dict data-type

This commit is contained in:
2024-04-21 14:24:56 +02:00
parent b28d6a8f02
commit 323308d86f
9 changed files with 160 additions and 9 deletions
+8 -2
View File
@@ -23,8 +23,14 @@ func newVarTerm(tk *Token) *term {
// -------- eval func
func evalVar(ctx ExprContext, self *term) (v any, err error) {
var exists bool
if v, exists = ctx.GetVar(self.tk.source); !exists {
err = fmt.Errorf("undefined variable %q", self.tk.source)
name := self.source()
if v, exists = ctx.GetVar(name); !exists {
info := ctx.GetFuncInfo(name)
if info != nil {
v = info.Functor()
} else {
err = fmt.Errorf("undefined variable or function %q", name)
}
}
return
}