OxL Reference

error positional-literal

error Standard: [§4.3]

What it means#

A positional literal T(e1, e2, ...) is allowed only when all fields are visible, the type is not @sealed, and the type has at most 4 fields without a default value (§4.3). In other cases the call is resolved to T.new(...) if it exists; otherwise it is an error.

Example#

oxl✓ checked in CI
data Order {
  id: u64
  user: u64
  item: u64
  qty: u32
  price: u64
}

fn main() {
  let o = Order(1, 2, 3, 4, 5)      // <- positional-literal (5 required fields)
}
error
positional-literal

How to fix#

oxl✓ checked in CI
data Order {
  id: u64
  user: u64
  item: u64
  qty: u32
  price: u64
}

fn main() {
  let o = Order{ id: 1, user: 2, item: 3, qty: 4, price: 5 }
}

Use a named literal T{ field: value }, or declare init new(...) so that T(args) resolves to it.

See also#

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