Docs: Built in functions shadow user variables
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 62/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- go
- Domain
- documentation
Research direction
Start with the language definition at https://expr-lang.org/docs/language-definition and review how built-in functions are documented. Add a warning about name collisions such as count > 0, mention the $env.count workaround and the API options for disabling functions, and include a link to the API documentation.
Written by the indexing model from the issue text.
Description
Problem:
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.
Proposed text (discussion starter, MVP):
The built in functions may cause issues in evaluation when the variables share the same name. It's very common to use
count > 0expressions in simplistic checks, producing an error. You can change the expression to$env.countto 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
- Dominant language
- Go
- Stars
- 8k
- Forks
- 529
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from expr-lang/expr
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
log2 builtin Open
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
enhancement needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
kind/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kubernetes-sigs/kueue#15947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·