182 Commits
Author SHA1 Message Date
Anton Medvedev 64df7b63f7 Add more tests 2025-09-18 21:39:22 +02:00
Andreev FedorandGitHub fd562c5c2a Fix error position reporting in multiline script (#827) 2025-09-08 10:40:52 +02:00
125b43e22f Fix runtime error not allowing to slice unaddressable array type (#803)
* fix runtime error not allowing to slice unaddressable array type

* simplify logic and move test

* remove dead code

---------

Signed-off-by: Anton Medvedev <[email protected]>
Co-authored-by: Anton Medvedev <[email protected]>
2025-06-30 20:21:25 +02:00
13992b0526 Ignoring fields with struct tag expr:"-" and make "in" return false for unexported fields (#806)
* allow ignoring struct member using a - in expr struct tag

* fix in operator

* simplify logic

* add regression test for #807

* fixes #807: make in operator return false for unexported struct fields

---------

Co-authored-by: Anton Medvedev <[email protected]>
2025-06-30 20:14:08 +02:00
Anton MedvedevandGitHub 037ef3dc3d Add expr.MaxNodes() option (#799)
* Add expr.MaxNodes() option

* Fix error message

* Add more tests and comments
2025-06-03 17:31:46 +02:00
Vincent BernatandGitHub c76a6cf3e8 Do not repeat patcher definition in ExamplePatch() (#792)
I suppose at some point, godoc was not smart enough to display the
definitions used in the body of examples in the documentation. This is
not the case anymore: https://pkg.go.dev/github.com/expr-lang/expr#example-Patch
2025-05-26 10:03:53 +02:00
2pacandGitHub 9e10dcd6b4 fix(785): get to work when return is nil (#786)
* fix(785): `get` to work when return is `nil`

* improve testing
2025-05-12 18:32:48 +02:00
Anton MedvedevandGitHub 452d355706 Make expr.Eval faster (#775)
* Make expr.Eval faster

* Add bench_call_test.go

* Make parser config optional
2025-03-24 14:48:41 +01:00
Anton Medvedev 6c8437454d Update fuzz tests 2025-03-08 16:19:30 +01:00
Anton Medvedev 8cab964afb Improve type checker for named types 2025-03-08 15:33:37 +01:00
Anton Medvedev 5aada75b87 Add SequenceNode to compiler 2025-03-08 12:46:59 +01:00
Anton Medvedev dea75b14d8 Add more tests for filter_map optimization 2025-03-07 21:52:14 +01:00
Anton Medvedev 127f965eeb Do not optimize filter_map if #index used
Fixes #758
2025-03-07 20:39:53 +01:00
Anton Medvedev 454f913c95 Make len() return runes count for string
Fixes #746
2025-03-07 16:58:35 +01:00
96320d0603 ci: add Go 1.23/1.24 testing and fix example test names (#760)
Expand test coverage to newer Go versions and fix compatibility issues:

- Add Go 1.23 and 1.24 to test matrix in test.yml
- Add Go 1.24 to build matrix in build.yml
- Fix example test names to match Go conventions:
  * ExampleOperator_Decimal → ExampleOperator_with_decimal
  * ExampleWithTimezone → ExampleTimezone
  * ExampleGetUnifiedDiffCode → ExampleGetUnifiedDiffString
  * ExampleGetContextDiffCode → ExampleGetContextDiffString
  * ExampleGetContextDiffString → ExampleGetContextDiffString_second

These changes maintain compatibility with Go 1.18 (as specified in
go.mod) while ensuring the codebase works correctly with the latest
Go versions, which enforce stricter naming conventions for example
tests.

Signed-off-by: Ville Vesilehto <[email protected]>
Co-authored-by: Anton Medvedev <[email protected]>
2025-03-02 09:31:59 +01:00
5000e417f5 Add if-else conditional (#736)
Co-authored-by: Anton Medvedev <[email protected]>
2025-02-23 14:19:51 +01:00
Anton Medvedev a8aece8708 Drop types.StrictMap and add types.Extra to define additional keys 2024-08-28 22:47:47 +02:00
Anton MedvedevandGitHub d0aa2e9136 Improve types pkg (#668) 2024-06-05 01:14:25 +02:00
Anton MedvedevandGitHub c953d0dde1 Refactor types table (#667) 2024-06-04 00:08:01 +02:00
Anton MedvedevandGitHub fee5690347 Refactor checker to use Nature (#665)
This PR introduces a new concept inside Expr's type checker - Nature.

It's an abstraction other reflect.Type which carries additional information about possible type, methods and builtin function.

I was able to find and fix a few bugs in type checker and optimizer. Implementation of nature concept has proven itself. As well nature will allow to bring more feature for type checker in future.

Why Nature? I was looking for a name to replace Type. Type name already carries much information, as well can be confused with reflect.Type. Nature name should be understood as "nature of the node", same as "type of the node".
2024-06-01 00:09:22 +02:00
Anton MedvedevandGitHub 19b2c3848f Add checks for nil before string casts in VM (#654) 2024-05-17 19:40:20 +02:00
Anton MedvedevandGitHub 696844a709 Refactor lexer (#653) 2024-05-17 18:10:26 +02:00
Anton Medvedev 71e349971e Add better error messages for index out of bounds errors 2024-05-12 11:55:15 +02:00
Anton Medvedev cea9c8ae86 Add int overflow checks 2024-05-09 17:22:41 +02:00
Anton MedvedevandGitHub 68e3148c1f Vendor testify (#642) 2024-05-08 00:24:35 +02:00
Anton Medvedev c6cd675d6b Add default timezone option expr.Timezone() 2024-05-07 23:19:39 +02:00
Anton Medvedev 3ceff1cdb3 Fix printing on conditional/binary nodes
Fixes #613
2024-04-16 23:23:12 +02:00
Anton Medvedev c8f7d22462 Return proper nil from optional chain
Fixes #570
2024-04-16 23:11:01 +02:00
Anton Medvedev c5dfe3a811 Make count() predicate optional 2024-04-13 23:38:35 +02:00
Anton Medvedev 8589d34039 Add sum([]) optimization 2024-04-13 23:16:08 +02:00
SergeyandAnton Medvedev 2c460ecc98 Optimize boolean operations between all, any, none functions (#626) 2024-04-13 10:09:16 +02:00
SergeyandAnton Medvedev 721b908494 expr.Operator passes before expr.Env caused error (#606) 2024-04-13 10:08:46 +02:00
Ganesan KaruppasamyandAnton Medvedev 527f3aacaf Fix -1 not in [] expressions (#590) 2024-04-13 10:08:10 +02:00
SergeyandAnton Medvedev 2be09b2554 Support chzained comparisonc1 < 2 < 3 (#581) 2024-04-13 10:08:10 +02:00
bizy 5bb64800db Compare any arrays 2024-02-28 00:30:33 +07:00
Ganesan KaruppasamyandGitHub 2f8f25a68d Enhanced min and max built-in functions to Support Arrays of Integers and Floats (#576)
* Enhanced min and max built-in functions to Support Arrays of Integers and Floats

* Enhanced min and max built-in functions to Support Arrays of Integers and Floats
2024-02-24 21:12:51 +01:00
Anton MedvedevandGitHub 0d43107999 Add concat() builtin (#565)
* Add concat() builtin

* Use pkg deref in builtin

* Use pkg deref in checker

* Use pkg deref in types_table.go

* Use pkg deref in docgen.go

* Use pkg deref in vm
2024-02-16 22:32:35 +01:00
Vladimir FetisovandGitHub c7c060ff44 Fix operator overloading (#554) 2024-02-08 21:07:58 +01:00
SergeyandGitHub 8d2e6b133c Add optional array access like foo?.[42] (#550) 2024-02-08 12:20:20 +01:00
SergeyandGitHub a0e2fe3664 Fix string literal slicing error (#543) 2024-01-31 18:07:26 +01:00
Anton Medvedev 616653130e Make AsAny the new default 2024-01-21 11:55:30 +01:00
Anton MedvedevandGitHub 010c934215 Fix race cond in variabels (#523)
* Add race cond test

* Move variables array to vm

* Resize vars array for different programs
2024-01-13 20:41:14 +01:00
a0db9a6c19 feat: Implement Bitwise and Shift Operator Support (#496)
Co-authored-by: Ganesan Karuppasamy <[email protected]>
2023-12-25 18:25:26 +01:00
Anton Medvedev 78d561792e Add timeout to test 2023-12-22 23:09:31 +01:00
Anton Medvedev ec98bc8cb9 Add custom tests 2023-12-22 22:48:59 +01:00
Anton Medvedev 4744fe1673 Rename test case 2023-12-19 20:58:34 +01:00
Anton Medvedev 6a7a977315 Add additional ember test 2023-12-19 08:40:13 +01:00
Sergey GrebenshchikovandGitHub 3426d4bcce Fix: checker panic on embedded pointer to struct field (#500)
* add failing test case: embedded pointer to struct

* fix(dereference embedded pointers to structs)

* add evaluation test for field access and method call on embedded pointer struct
2023-12-18 21:46:31 +01:00
Anton Medvedev dd73db72ed checker: forbid accessing custom functions from $env 2023-12-10 10:44:43 +01:00
Anton Medvedev 551d2a7e0f Use expr-lang/expr 2023-12-03 21:53:01 +01:00