Docs: Built in functions shadow user variables

Open Beginner friendly
#905 0 comments 0 reactions 0 assignees View on GitHub

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

docs needed

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 > 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

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from expr-lang/expr

All issues in expr-lang/expr

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.