Skip to content

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

Closed
@glicht

Description

@glicht

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions