OxL Reference

error chained-comparison

error Standard: [§5.2]

What it means#

The comparison operators == != < <= > >= <=> in have precedence level 4 and no associativity (§5.2), so a < b < c is an error rather than a silently surprising (a < b) < c.

Example#

oxl✓ checked in CI
fn inRange(x: i32) -> bool {
  0 < x < 10      // <- chained-comparison
}
error
chained-comparison

How to fix#

oxl✓ checked in CI
fn inRange(x: i32) -> bool {
  0 < x && x < 10
}

Join the comparisons explicitly with &&, or use a range test such as x in 1..10.

See also#

OxL 1.0.0-beta · Documentation version 1.0.0-beta© OxwaldLink · generated from the Standard, the std sources and the guides