cue-lang/cue

evaluator: undocumented (and inconsistent?) bounds on bounds

Opened this issue · 1 comments

What version of CUE are you using (cue version)?

the playground (v0.5.1-0.20230413144408-f681271a38ec)

What did you do?

a: >(<=3)
b: <(<=3)
c: <(<3)
d: <=(<3)

What did you expect to see?

AFAICT, this behaviour is undocumented. My expectation would be for the four lines to resolve to the following errors, respectively:

invalid operand (<=3) ('>' requires concrete value)
invalid operand (<=3) ('<' requires concrete value)
invalid operand (<3) ('<' requires concrete value)
invalid operand (<3) ('<=' requires concrete value)

This would be consistent with how most other unary operators (such as ! and -) require concrete values.

What did you see instead?

a: number
b: <3
c: <3
d: <3

What bothers me with this one is that the result feels inconsistent? For a, i interpret the bound as "must be greater than a value that is less than 3", which, yes, is any value of the type, hence number. Similarly, for b, the bound can be interpreted as "must be strictly smaller than a number that is smaller or equal to 3", therefore strictly smaller than 3. But the same logic does not hold for c for integers.

Shouldn't this behaviour be documented as part of the language reference?

myitcv commented

In the interests of getting v0.6.0 out, and because we might end up with duplicate work on v0.6.0 and v0.7.0 for this issue, pushing to v0.7.0 for now.