You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Docs: Built in functions shadow user variables #905
When using go-expr in default mode, functions are enabled. The function list includes some commonly defined variables, like count, and leads to expression compilation errors in cases like count > 0.
Solution:
The API exports functions that allow disabling a particular built-in function, or disabling them all. No implementation is necessary to work around the issue, and the issue also has other solutions like $env.count.
Proposal:
The language definition seems to be the canonical source of truth for which functions are implemented in go-expr. I'd like if a warning could be added that mentions the problem, and the option to disable the built in functions is possible via API.
The built in functions may cause issues in evaluation when the variables share the same name. It's very common to use count > 0 expressions in simplistic checks, producing an error. You can change the expression to $env.count to avoid the issue. The API allows to disable built in functions, avoiding issues when you don't have control over the input and mainly want to use other features of expr like conditions and ternary operators. See the API documentation
Activity