google / cel-spec

Common Expression Language -- specification and binary representation
https://cel.dev
Apache License 2.0
2.78k stars 222 forks source link

Numeric Comparison Improvements #210

Closed TristonianJones closed 2 years ago

TristonianJones commented 2 years ago

CEL should consider numeric comparisons (<, <=, =>, >) as though the values exist on a contiguous number line irrespective of the numeric representation (int, uint, double). It is possible to support such comparisons without any numeric conversion by introducing specialized overloads for all possible combinations of types, e.g. int_less_than_uint, etc.

Numeric equality should also be supported across all numeric types at runtime. However, this is generally dangerous when it comes to comparisons containing floating point values. Thus, the CEL type-checker should continue to signal this case as an error if it can detect it and request that users explicitly type convert as this is a very low-overhead.

TristonianJones commented 2 years ago

This change has been introduced into the conformance suite in #220 and #231, and is being added to the spec in #232