Repository navigation
Releases
v1.18.1
Expr is an expression language designed to deliver dynamic configurations with unparalleled accuracy,
safety, and speed.
program, err := expr.Compile(`let foo = bar(); baz(foo, foo)`)In this release:
- Security: type check nested calls of overloaded functions in linear time. Compile time used to grow exponentially with nesting depth, so a short expression such as 42 nested
replacecalls never finished compiling (GHSA-6h63-3f9q-wq5h, #1010) - Security:
reversechecks the memory budget before allocating its result (#1006) - Performance:
uniqno longer compares each element against every kept value; up to 98% faster on lists with many distinct values (#1007)
Upgrading from v1.18.0 requires no changes.
v1.18.0
Expr is an expression language designed to deliver dynamic configurations with unparalleled accuracy,
safety, and speed.
program, err := expr.Compile(`let foo = bar(); baz(foo, foo)`)In this release:
- Security: limit expression nesting depth to prevent a fatal stack overflow on deeply nested input (#1003)
- Security: enforce
MemoryBudgetfor string concatenation and string-producing builtins (#1003) - New feature: added
merge()builtin for combining maps (#947) - New feature: added
log2()builtin (#981) - New feature: support
DisableBuiltin("$env")to hide the$envvariable (#949) - New feature: allow field access on concrete types behind interface values (#952)
- New feature: support optional chaining on slice expressions, e.g.
foo?.[0:1](#945) - Fixed:
DisableBuiltinandDisableAllBuiltinsnow apply to predicate builtins such asall,filterandmap(#1005) - Fixed: compile-time panic on field access after the
filter(...)[0]optimization (#1004) - Fixed: panic in
ConstantNode.Stringon NaN and infinite floats (#974) - Fixed: evaluate the third argument of
reduceandsortByin the enclosing scope (#1002) - Fixed: add
sum([...])elements left to right, matching unoptimized results (#999) - Fixed: resolve embedded-interface fields in
get()(#977) - Fixed: reject pointer-to-map environment with a clear error (#987)
- Fixed: check struct field name is a string in
Fetchandget()(#973) - Fixed: reject non-comparable keys in
fromPairs()(#964) - Fixed: reject negative count in
take()(#965) - Fixed: pop stale bool from stack in
emitLoopBackwards(#954) - Fixed: clear error when fetching a field from a string at runtime (#963)
- Fixed: handle non-comparable
groupBykeys (#940) - Fixed: reject unexported struct fields at runtime (#935)
- Fixed: wrap
LoadLocationerror indate()(#931) - Docs: map literal key types (#998),
WithContextsignature requirements (#997),minandmaxarguments (#985)
Upgrade notes:
- Memory budget: string concatenation and builtins such as
repeat,replace,join,split,toJSONandtoBase64now count againstMemoryBudget. Programs that build very large strings (over about 1 MB with the default budget) may now fail withmemory budget exceeded. Raise the limit withexpr.MemoryBudget(...)if needed. - Custom
Safebuiltins:builtin.Function.Safeandvm.SafeFunctionnow receive the remaining memory budget as their first argument:func(budget uint, args ...any) (any, uint, error). Add a_ uintparameter to existing implementations. DisableAllBuiltins()now also disables predicate builtins (all,any,none,one,filter,map,count,sum,find,findIndex,findLast,findLastIndex,groupBy,sortBy,reduce). Re-enable the ones you need withexpr.EnableBuiltin(...).- Nesting limit: expressions nested more than 10,000 levels deep are rejected at compile time.
v1.17.8
Expr is an expression language designed to deliver dynamic configurations with unparalleled accuracy,
safety, and speed.
program, err := expr.Compile(`let foo = bar(); baz(foo, foo)`)In this release:
- New feature: added bytes literal syntax (#894)
- Improved performance: count comparisons to any (#897)
- Improved performance: added sum range optimization (#896)
- Improved performance: added count threshold comparisons (#898)
- Improved performance: optimize loop iteration with scope pool (#908)
- Improved performance: added fast paths for min, max, mean, and median (#909)
- Fixed: ctx into nested custom funcs and Env (#883)
- Fixed: disable check for missing predicate during parseing (#924)
- Fixed: detect $env() calls at compile time (#923)
- Fixed: bounds check to get() (#918)
- Fixed: validate sortBy order argument type (#912)
- Fixed: reduce empty array without init val (#911)
- Fixed: validate arg count before OpCall (#904)
- Fixed: correct variadic method arg type (#889)
v1.17.7
Expr is a Go-centric expression language designed to deliver dynamic configurations with unparalleled accuracy,
safety, and speed.
program, err := expr.Compile(`let foo = bar(); baz(foo, foo)`)This release brings new language features, performance improvements across runtime and compiler, better error
handling, and many important bug fixes.
New Features
Support for else if expressions
- You can now chain conditional branches using
else if! (#879)
Unicode escapes in the \u{XXXXXX} format
- String literals now support Unicode code point escapes such as
\u{1F600}. (#882)
Byte slice support in the matches operator
The matches operator now works with []byte, improving interoperability with binary data. (#876)
Short-circuit control options
New options allow enabling or disabling short-circuiting behavior in the compiler and VM. (#847)
Option to disable if operator
A separate DisableIfOperator option is now available. (#881)
Performance Improvements
Runtime structure fetch improvements
Accessing struct fields at runtime is now faster. (#833)
VM function call optimizations
Function calls inside the VM execute more efficiently. (#832)
Type system performance boost
Large or complex type operations now run significantly faster. (#824)
Bug Fixes
- Guard negative forward jump offsets (#861).
- Prevent stack underflow in the VM (#860).
- Correct behavior of
AsBoolwith nil and undefined variables (#866). - Proper handling of nil arguments in variadic functions (#868).
- Show function name for safe calls in disassembly (#869).
- Limit recursion depth in built-in functions (#870).
- Throw an error when a predicate is missing in the parser (#842).
- Fixed array type resolution in conditional operator (#865).
- Disallow access to unexported struct fields (#846).
- Fixed retrieving field pointers in structs (#843).
- Better error position reporting in multi-line scripts (#827).
- Support quoting backticks inside string literals (#820).
- Fixed auto-dereference for maps/slices and conditionals (#871).
- Wrap merged optimizer results as predicates (#864).
- Improved missing property handling (#854).
- Handle invalid
ifconditions and detect null-byte crashes. - Added regression tests for several reported issues.