OxL Reference

error pattern-bindings

error Standard: [§5.5]

What it means#

In an alternative pattern A | B every branch MUST bind the same set of names (§5.5), otherwise the name would be undefined when the other branch matches.

Example#

oxl✓ checked in CI
enum Shape { Circle(r: f64), Rect(w: f64, h: f64) }

fn size(s: Shape) -> f64 {
  match s {
    Circle(r) | Rect(w, _) => 1.0      // <- pattern-bindings (r vs w)
  }
}
error
pattern-bindings

How to fix#

oxl✓ checked in CI
enum Shape { Circle(r: f64), Rect(w: f64, h: f64) }

fn size(s: Shape) -> f64 {
  match s {
    Circle(r) => r
    Rect(w, _) => w
  }
}

Bind the same names in every alternative, or split the alternatives into separate arms.

See also#

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