OxL Reference

error bad-init

error Standard: [§4.3]

What it means#

A named constructor init name(params) -> Self | E is an associated function whose return type MUST be Self or a union that contains Self (§4.3). Errors may be added to the union; other result types are not constructors.

Example#

oxl✓ checked in CI
data Account { id: u64 }

impl Account {
  init open(id: u64) -> u64 => id      // <- bad-init
}
error
bad-init

How to fix#

oxl✓ checked in CI
data Account { id: u64 }

impl Account {
  init open(id: u64) -> Self => Self{ id }
}

Return Self (or Self | SomeError). If the function is not a constructor, declare it with static fn instead.

See also#

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