Skip to content

Releases: expr-lang/expr

v1.12.1

22 Feb 22:58
Compare
Choose a tag to compare
  • Fixed a bug with builtins and nil argument.

v1.12.0

03 Feb 14:56
Compare
Choose a tag to compare
  • Added nil coalescing operator ??.

Example:

user?.Name ?? "Anonymous"

v1.11.1

03 Feb 10:07
Compare
Choose a tag to compare
  • Fixed abs() for positive numbers

v1.11.0

02 Feb 08:41
Compare
Choose a tag to compare

Expr – an expression language for Go.

This release introduces a new API for defining functions inside Expr - expr.Function.

From an Expr expression is already possible to call any Go methods and functions, but Expr has to use reflect package in doing such calls.
In previous releases, Expr added a special case for func (...any) any to avoid using reflect. But such functions lack type information. With newly added expr.Function option now it's possible to define a fast function with optional types! Read more in the docs.

atoi := expr.Function(
	"atoi",
	func(params ...any) (any, error) {
		return strconv.Atoi(params[0].(string))
	},
	new(func(string) int),
)

program, err := expr.Compile(`atoi("42")`, atoi)

Also in this release:

  • Added bool condition optimization.
  • Added support for comments // and /* ... */.
  • Added support for negative indexes list[-1].
  • Predicate brackets are now optional all(list, .values > 0).
  • Added int() and float() builtins.
  • Improved built-in functions performance.

v1.10.5

24 Jan 18:57
Compare
Choose a tag to compare
  • Fixed call typed to exclude named functions.
  • Fixed type check for in operator with any on rhs.

v1.10.4

23 Jan 20:29
Compare
Choose a tag to compare
  • Fixed checker to correctly expect type cast with As*() modifiers.

v1.10.3

22 Jan 18:47
Compare
Choose a tag to compare
  • Fixed nil type check.

v1.10.2

21 Jan 12:44
Compare
Choose a tag to compare
  • Added more typed call signatures.
  • Fixed: correctly check error type of func return types.
  • Fixed: use CallTyped for methods as well.

v1.10.1

20 Jan 20:51
Compare
Choose a tag to compare
  • Fixed: CallFastTyped kind detection.
  • Fixed type checker: allow to use any as key in maps.
  • Fixed: put operator check after env is set (#309).

v1.10.0

19 Jan 10:33
154081e
Compare
Choose a tag to compare

Expr – expression language and expression evaluation for Go.

out, err := expr.Eval(`all(Tweets, {.Len <= 240})`, tweets)

In this release

  • Performance improved up to 50%-100%.
  • Added native support for times and duration.