enabled passing functions as parameters in function call
This commit is contained in:
parent
f1afbf9b49
commit
43e631f2e8
@ -24,11 +24,11 @@ func TestExpr(t *testing.T) {
|
||||
succeeded := 0
|
||||
failed := 0
|
||||
|
||||
// inputs1 := []inputType{
|
||||
// {`1 ? {"a"} : {"b"} ? ["a"] {"A"} :["b"] {"B"}`, "B", nil},
|
||||
// }
|
||||
inputs1 := []inputType{
|
||||
{`f = func(op){op()}; f(func(){2})`, int64(2), nil},
|
||||
}
|
||||
|
||||
for i, input := range inputs {
|
||||
for i, input := range inputs1 {
|
||||
var expr Expr
|
||||
var gotResult any
|
||||
var gotErr error
|
||||
|
@ -89,7 +89,12 @@ type funcDefFunctor struct {
|
||||
func (functor *funcDefFunctor) Invoke(ctx ExprContext, name string, args []any) (result any, err error) {
|
||||
for i, p := range functor.params {
|
||||
if i < len(args) {
|
||||
ctx.setVar(p, args[i])
|
||||
arg := args[i]
|
||||
if functor, ok := arg.(Functor); ok {
|
||||
ctx.RegisterFunc(p, functor, 0, -1)
|
||||
} else {
|
||||
ctx.setVar(p, arg)
|
||||
}
|
||||
} else {
|
||||
ctx.setVar(p, nil)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user