28 Commits
Author SHA1 Message Date
a60d994e25 Improve Performance of the Type System (#824)
* export the checker and ensure no methods or fields are exported

* make Checker reusable

* add PatchAndCheck method to Checker, and reuse it in visitors

* avoid unnecessary map and consolidate structs

* make all Nature methods use pointer-receiver

* added cache for type and nature information

* optimize type and nature checks

* more aggressively cache some partial results and add cheap checks

* cache reused values

* reduce copying in Nature by breaking down optional fields

* enforce use of cache

* improve ergonomics of FromType and NatureOf

* improve struct method fetching

* make cache private to Nature

* first iteration improving struct reflect caching

* cleaned up struct fields data

* improve caching of functions data

* simplify checker code

* simplify and remove dead code

* add checker benchmarks

* address PR comments and minor improvements

* rename from SetCache to Bind

* make the benchmarks more fair

* fix benchmark option not being applied

* move Cache to be argument instead of field

* merge FuncData into Optional

* rename Optional to TypeData

* simplify struct logic

* cache builtin numeric types

---------

Co-authored-by: Anton Medvedev <[email protected]>
2025-09-18 14:38:27 +02:00
Diego Augusto MolinaandGitHub fefc347053 Improve parser and lexer (#811)
* convert source to a struct and fix minor issue displaying error

* lexer: add byte and char pos

* improve parser to use string instead of []rune

* add lexer benchmarks

* make lexer work as an iterator

* make parser use the new iterator API in lexer

* allow reusing the parser

* cleanup code

* add parser benchmarks
2025-06-30 20:08:46 +02:00
Anton Medvedev 31f0ab00dc Remove duplicated dereferences 2025-03-10 13:52:54 +01:00
Anton Medvedev 3fc6c1f535 Make all builtins working with deref
Fixes #730
2025-03-08 17:01:31 +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
Nathan BaulchandGitHub 0dd69ea8ca Fix typos (#745) 2025-01-09 13:33:28 +01:00
Simon WaldherrandGitHub 42eec6f21f Fix typos (#686) 2024-07-14 09:07:58 +02:00
Anton MedvedevandGitHub 68e3148c1f Vendor testify (#642) 2024-05-08 00:24:35 +02: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
Anton Medvedev e5049dfda3 Make conf top-level package 2020-03-16 16:29:25 +03:00
Anton Medvedev cd6348b6bf Add expr.Patch func 2020-03-16 16:29:25 +03:00
Anton MedvedevandGitHub acba548cab Add ConstExpr 2020-03-10 08:36:12 +03:00
Anton Medvedev 0223fa9f0c Make type checking non-strict by default 2020-03-06 14:26:58 +03:00
Anton Medvedev de5d4adc5d Lexer first commit 2020-02-25 09:33:17 +03:00
fa91adf0ac Allow passing nil to functions as nil interface{} (#87)
* Update vm.go

golang gotcha: reflect calls with nil params fail without this trick

* Update vm.go

* Problem with passing "nil" when operators are overloaded with interface{} type parameters fixed

e.g.
a != nil
was not working when "!=" is overloaded with
func notEqual(a, b interface{}) interface{} {...}

* Compile fix

Forgot to close ")"

* Added test that illustrates what did not work when using overloaded operators and passing nil

* Updated test for overloaded eaqal with using nil

a == b replaced with a == nil to illustrated the problem when using nil directly in expression

* Fixed the problem for untyped nil

We use the trick only for untyped nil:
https://play.golang.org/p/MyAztoZaqhx

* Refactor call procedure

Co-authored-by: wintermute-cds <[email protected]>
2020-02-20 16:59:15 +03:00
TarasZakandAnton Medvedev 10b48c0915 Add compile checks for undefined variables (#85)
* Add compile checks for undefined variables

* Update expr_test.go

Co-authored-by: Anton Medvedev <[email protected]>
2020-01-24 14:53:53 +03:00
Anton Medvedev 8564cbf597 Add option to allow using undefined variables 2019-11-07 12:17:02 +03:00
ElliotandAnton Medvedev b7f2bedd10 Move conf.Options out of internal package 2019-10-18 10:32:59 +03:00
Anton Medvedev 9aac713478 Add docgen 2019-08-26 11:34:51 +07:00
Anton Medvedev 80bb7ad498 Add interface support to operator overloading 2019-08-08 16:20:57 +03:00
Anton Medvedev db181aa452 Add ability to use operator overloading with methods 2019-08-08 15:39:19 +03:00
Anton Medvedev 4547b362d9 Add constant folding optimization 2019-06-25 15:42:57 +03:00
David KlassenandAnton Medvedev 639b06587c Allow overloading binary node with a function from env 2019-06-23 15:10:54 +03:00
Anton Medvedev 08ac84ad03 Add cast feature 2019-06-22 15:15:58 +03:00
Anton Medvedev aaab4a59b1 Add new internal package conf 2019-06-22 14:22:19 +03:00
Anton Medvedev dad75c763f Make file package's struct marshallable 2019-06-07 17:06:49 +03:00
Anton Medvedev fb30511dd7 Refactor helper package to file package 2019-06-07 16:47:22 +03:00
Anton MedvedevandGitHub ef410b0f3f expr v2 2019-05-28 00:09:22 +07:00