-
Notifications
You must be signed in to change notification settings - Fork 54
Description
Describe the bug
When evaluating a unary test that uses the built-in sum function with ? as the input (sum(?) < 112), the result is false, although the same condition expressed with a named parameter (sum(list: ?) < 112) or as a normal expression is true.
So:
sum(?) < 112 → unary tests: false
sum(list: ?) < 112 → unary tests: true
count(?) < 112 → unary tests: true
According to the FEEL semantics, unary tests should allow arbitrary expressions with ? as the input value, and sum(?) should behave the same as sum(list: ?) when the input is a list.
Environment
feel-engine: 1.19.3
Language: Java (Spring Boot service)
API used: FeelEngineApi#evaluateUnaryTests
Suspected root cause
sum is declared as a varargs built-in function. The varargs handling is done in FeelInterpreter.invokeFunction, where positional parameters are repacked into a ValList for functions with hasVarArgs = true.
In unary tests, the ? handling goes through UnaryTestExpression and getImplicitInputValue. With sum(list: ?) (named parameter) everything works, but with sum(?) (positional vararg) the unary test result for sum(?) < 112 ends up being false, even though sum(list: ?) < 112 and the corresponding normal expression are true.
count is not declared as varargs and works fine with count(?).
This suggests an inconsistency/bug in how varargs built-ins are invoked in the context of unary tests with positional parameters.
Expected behavior
evaluateUnaryTests("sum(?) < 112", List.of(1, 2, 3), …) should return true, just like:
evaluateUnaryTests("sum(list: ?) < 112", List.of(1, 2, 3), …) and
evaluateExpression("sum(input) < 112", Map.of("input", List.of(1, 2, 3))).
Metadata
Metadata
Assignees
Labels
Type
Projects
Status