OxL Reference

error sealed-literal

error Standard: [§4.3]

What it means#

@sealed forbids literals outside the impl of the type; values are built only by init constructors (§4.3). This lets the type guarantee its invariants.

Example#

oxl✓ checked in CI
@sealed data Account {
  id: u64
  balance: i64
}

impl Account {
  init new(id: u64) -> Self => Self{ id, balance: 0 }
}

fn main() io {
  let a = Account{ id: 1, balance: 100 }      // <- sealed-literal
  print("{a.balance}")
}
error
sealed-literal

How to fix#

oxl✓ checked in CI
@sealed data Account {
  id: u64
  balance: i64
}

impl Account {
  init new(id: u64) -> Self => Self{ id, balance: 0 }
}

fn main() io {
  let a = Account.new(1)
  print("{a.balance}")
}

Call one of the init constructors (Account.new(1)) or add a constructor that fits your need.

See also#

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