cel-python icon indicating copy to clipboard operation
cel-python copied to clipboard

Condition syntax sometimes evaluates the wrong branch

Open sewi-cpan opened this issue 1 year ago • 0 comments

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.

sewi-cpan avatar Dec 06 '23 12:12 sewi-cpan