github expr-lang/expr v1.18.0

one hour ago

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.

Don't miss a new expr release

NewReleases is sending notifications on new releases.