cel-python
cel-python copied to clipboard
Condition syntax sometimes evaluates the wrong branch
false ? true.exists_one(i, false) : false raises *BoolType* object is not iterable.
Expected: The first false should skip the first branch of the condition and execute the "else" branch (the last false).
The CEL language definition says:
To get traditional left-to-right short-circuiting evaluation of logical operators, as in C or other languages (also called "McCarthy Evaluation"), the expression e1 && e2 can be rewritten e1 ? e2 : false. Similarly, e1 || e2 can be rewritten e1 ? true : e2.
This error doesn't happen for false ? 1/0 : true. This condition correctly skips the division by zero.