OxL Reference

error bound-not-satisfied

error Standard: [§4.8]

What it means#

A type argument does not satisfy a bound of the generic parameter: an interface (T: Ord) or a where predicate (§4.8). The argument may be given explicitly or inferred from the call.

Example#

oxl✓ checked in CI
fn max<T>(a: T, b: T) -> T where T: Ord => if a > b { a } else { b }

data P { x: i32 }

fn main() {
  let m = max(P{ x: 1 }, P{ x: 2 })      // <- bound-not-satisfied (P is not Ord)
}
error
bound-not-satisfied

How to fix#

oxl✓ checked in CI
fn max<T>(a: T, b: T) -> T where T: Ord => if a > b { a } else { b }

@derive(Eq, Ord)
data P { x: i32 }

fn main() {
  let m = max(P{ x: 1 }, P{ x: 2 })
}

Make the type satisfy the bound (implement the interface or @derive it), or pass a different type.

See also#

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