-
Notifications
You must be signed in to change notification settings - Fork 352
evaluator: undocumented (and inconsistent?) bounds on bounds #2380
Description
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: <3What 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?