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

type coercion inconsistently fails depending on order of arguments

Open klarose opened this issue 6 months ago • 0 comments

I was surprised to find that a less-than comparison failed between an integer and a float, since I thought I had seen it work earlier. Sure enough, it works if the left hand side is a float, but not if the left hand side is an int.

Example:

# good
python -m celpy -n '4.0 < 10'
true

# bad
python -m celpy -n '10 < 4.0'
ERROR: <input>:1:1 found no matching overload for 'relation_lt' applied to '(<class 'celpy.celtypes.IntType'>, <class 'celpy.celtypes.DoubleType'>)'
    | 10 < 4.0

Both of these work in golang, see cel playground

I expect both statements to properly evaluate. This appears to affect a bunch of other operators (<=, >, >=)

klarose avatar Jun 25 '25 18:06 klarose