Hi @antonmedv
If there are 2 patched function calls within 1 function call, it doesn't compile.
https://go.dev/play/p/9dH2e9KuF2d
package main
import (
"context""fmt""time""github.com/expr-lang/expr"
)
typeenvstruct {
Ctx context.Context`expr:"ctx"`
}
funcmain() {
p, err:=expr.Compile(
"now2().After(date2())",
expr.Env(env{}),
expr.WithContext("ctx"),
expr.Function(
"now2",
func(params...any) (any, error) { returntime.Now(), nil },
new(func(context.Context) time.Time),
),
expr.Function(
"date2",
func(params...any) (any, error) { returntime.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), nil },
new(func(context.Context) time.Time),
),
)
iferr!=nil {
panic(err)
}
r, err:=expr.Run(p, &env{Ctx: context.Background()})
iferr!=nil {
panic(err)
}
fmt.Println(r)
}Output:
panic: not enough arguments to call date2 (1:14)
| now2().After(date2())
| .............^
goroutine 1 [running]:
main.main()
/tmp/sandbox2261374222/prog.go:32 +0x2d5
Hi @antonmedv
If there are 2 patched function calls within 1 function call, it doesn't compile.
https://go.dev/play/p/9dH2e9KuF2d
Output: