Skip to content

Releases

v1.18.1

Choose a tag to compare

@antonmedv antonmedv released this 22 Nov 13:09
399159a

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 replace calls never finished compiling (GHSA-6h63-3f9q-wq5h, #1010)
  • Security: reverse checks the memory budget before allocating its result (#1006)
  • Performance: uniq no 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

Choose a tag to compare

@antonmedv antonmedv released this 21 Nov 22:58
dc3f3a4

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 MemoryBudget for 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 $env variable (#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: DisableBuiltin and DisableAllBuiltins now apply to predicate builtins such as all, filter and map (#1005)
  • Fixed: compile-time panic on field access after the filter(...)[0] optimization (#1004)
  • Fixed: panic in ConstantNode.String on NaN and infinite floats (#974)
  • Fixed: evaluate the third argument of reduce and sortBy in 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 Fetch and get() (#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 groupBy keys (#940)
  • Fixed: reject unexported struct fields at runtime (#935)
  • Fixed: wrap LoadLocation error in date() (#931)
  • Docs: map literal key types (#998), WithContext signature requirements (#997), min and max arguments (#985)

Upgrade notes:

  • Memory budget: string concatenation and builtins such as repeat, replace, join, split, toJSON and toBase64 now count against MemoryBudget. Programs that build very large strings (over about 1 MB with the default budget) may now fail with memory budget exceeded. Raise the limit with expr.MemoryBudget(...) if needed.
  • Custom Safe builtins: builtin.Function.Safe and vm.SafeFunction now receive the remaining memory budget as their first argument: func(budget uint, args ...any) (any, uint, error). Add a _ uint parameter 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 with expr.EnableBuiltin(...).
  • Nesting limit: expressions nested more than 10,000 levels deep are rejected at compile time.

v1.17.8

Choose a tag to compare

@antonmedv antonmedv released this 14 Feb 13:25
21f4f05

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

Choose a tag to compare

@antonmedv antonmedv released this 15 Dec 19:33
d472286

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 AsBool with 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 if conditions and detect null-byte crashes.
  • Added regression tests for several reported issues.

v1.17.6

Choose a tag to compare

@antonmedv antonmedv released this 12 Aug 19:23
87df783

What's Changed

  • Improve parser and lexer by @diegommm in #811
  • Ignoring fields with struct tag expr:"-" and make "in" return false for unexported fields by @diegommm in #806
  • Fix runtime error not allowing to slice unaddressable array type by @diegommm in #803
  • Fix *vm.VM memory leak by @diegommm in #813

v1.17.5

Choose a tag to compare

@antonmedv antonmedv released this 03 Jun 15:32
eeb1b8b
  • Added expr.MaxNodes() option by #799

v1.17.4

Choose a tag to compare

@antonmedv antonmedv released this 27 May 10:14
ebf0d8b
  • Added check for non struct types to fetchField #794
  • Docs: do not repeat patcher definition in ExamplePatch() #792

v1.17.3

Choose a tag to compare

@antonmedv antonmedv released this 14 May 14:08
28d9b3d
  • Fixed get built-in to work with nil #786

v1.17.2

Choose a tag to compare

@antonmedv antonmedv released this 24 Mar 13:53
6121e25
  • Improved performance of expr.Eval #775

v1.17.1

Choose a tag to compare

@antonmedv antonmedv released this 18 Mar 09:50
e135bda
  • Fixed parsing of variable declaration nodes combined with sequence node in #773