From 0e4c3a7ec837bc919ebe5332bc3efdc11aa7c182 Mon Sep 17 00:00:00 2001 From: sanmaxdev Date: Mon, 6 Jul 2026 01:09:49 +0000 Subject: [PATCH] docs: clarify built-in name conflicts --- docs/language-definition.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/language-definition.md b/docs/language-definition.md index 69efbdfa9..2083c4809 100644 --- a/docs/language-definition.md +++ b/docs/language-definition.md @@ -346,6 +346,18 @@ filter(posts, { ::: +## Built-in Function Names + +Expr resolves built-in functions such as `count`, `len`, `map`, and `filter` +before environment variables with the same name. For example, if the +environment contains a variable named `count`, the expression `count > 0` is +parsed as a reference to the built-in `count` function and fails type checking. + +Use `$env.count` to access the environment value explicitly, or disable the +conflicting built-in with [`expr.DisableBuiltin("count")`](https://pkg.go.dev/github.com/expr-lang/expr#DisableBuiltin). +Use [`expr.DisableAllBuiltins()`](https://pkg.go.dev/github.com/expr-lang/expr#DisableAllBuiltins) +when an expression environment must reserve all function names for variables. + ## String Functions ### trim(str[, chars]) {#trim}