Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime error in logical boolean operators should be ignored when result is determined #79

Open
glicht opened this issue Dec 2, 2024 · 0 comments

Comments

@glicht
Copy link

glicht commented Dec 2, 2024

When running the following statements:

  • false && true.exists_one(i, false)
  • true || true.exists_one(i, false)

I get the following error: TypeError: 'BoolType' object is not iterable

According to the CELspec: https://github.com/google/cel-spec/blob/master/doc/langdef.md#logical-operators

In the boolean operators && and ||: if any of their operands uniquely determines the result (false for && and true for ||) the other operand may or may not be evaluated, and if that evaluation produces a runtime error, it will be ignored.

The runtime error should be ignored as the result is uniquely determined by the left hand side of the operator.

Note that the spec further states:

This makes those operators commutative (in contrast to traditional boolean short-circuit operators). The rationale for this behavior is to allow the boolean operators to be mapped to indexed queries, and align better with SQL semantics.

So if I understand correctly the following should also be ok and not throw an error:

  • true.exists_one(i, false) && false
  • true.exists_one(i, false) || true

Related: #50

Tested with main branch commit ref: 6b8e3cd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant