You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling a function that receives a single float (any other type seems to work properly), expr.Compile now allows the argument to be of any type.
These tests reflect the issue:
funcTestIssue(t*testing.T) {
t.Parallel()
testCases:= []struct {
namestringcodestringfailbool
}{
{
name: `when the parameter is a string`,
code: `func("invalid")`,
fail: true,
},
{
name: `when the parameter is a bool`,
code: `func(true)`,
fail: true,
},
{
name: `when the parameter is an array`,
code: `func([])`,
fail: true,
},
{
name: `when the parameter is a map`,
code: `func({})`,
fail: true,
},
{
name: `when the parameter is an integer`,
code: `func(1)`,
fail: false,
},
{
name: `when the parameter is a float`,
code: `func(1.5)`,
fail: false,
},
}
for_, tc:=rangetestCases {
ltc:=tct.Run(ltc.name, func(t*testing.T) {
t.Parallel()
function:=expr.Function("func", func(params...any) (any, error) {
returntrue, nil
}, new(func(float64) bool))
_, err:=expr.Compile(ltc.code, function)
ifltc.fail {
iferr==nil {
t.Error("expected an error, but it was nil")
t.FailNow()
}
} else {
iferr!=nil {
t.Errorf("expected nil, but it was %v", err)
t.FailNow()
}
}
})
}
}
The behavior was changed in v1.15.0 and still persists in v1.15.4.
The text was updated successfully, but these errors were encountered:
When calling a function that receives a single float (any other type seems to work properly),
expr.Compile
now allows the argument to be of any type.These tests reflect the issue:
The behavior was changed in v1.15.0 and still persists in v1.15.4.
The text was updated successfully, but these errors were encountered: