Skip to content

parser: respect disabled builtins for predicate functions - #1005

Merged
antonmedv merged 1 commit into
masterfrom
fix/841-disable-predicates
Nov 21, 2026
Merged

antonmedv merged 1 commit into
masterfrom
fix/841-disable-predicates

Conversation

@antonmedv

Copy link
Copy Markdown
Member

Fixes #841.

DisableBuiltin and DisableAllBuiltins had no effect on the predicate builtins: all, any, none, one, filter, map, count, sum, find, findIndex, findLast, findLastIndex, groupBy, sortBy and reduce. The parser handled these names before it checked the disabled list.

A disabled predicate now fails to compile with unknown name <name>. The error is raised in the parser, because predicate arguments like # > 0 can't be parsed as a regular call. As before, a function with the same name in the env or from expr.Function takes precedence.

Behaviour change: DisableAllBuiltins() now also disables map, filter, reduce and the other predicates, as its documentation says. Code that relied on them still working needs to call EnableBuiltin("map") and so on.

The new test covers all 15 predicates with DisableBuiltin, DisableAllBuiltins and EnableBuiltin. The change only affects compile time, so it has no runtime cost.

DisableBuiltin and DisableAllBuiltins had no effect on predicate builtins
(all, any, none, one, filter, map, count, sum, find, findIndex, findLast,
findLastIndex, groupBy, sortBy, reduce), because the parser handled them
before checking the disabled list.

A disabled predicate now fails with "unknown name", unless it is
overridden by the env or expr.Function.

Fixes #841
@antonmedv
antonmedv merged commit badd365 into master Nov 21, 2026
23 checks passed
@antonmedv
antonmedv deleted the fix/841-disable-predicates branch November 25, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

expr.Disable*() functions are not working

1 participant