OxL Справочник OxL
РусскийEnglish

error bad-init

error Стандарт: [§4.3]

init должен возвращать Self или объединение с Self.

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✓ проверяется в CI
data Account { id: u64 }

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

How to fix#

oxl✓ проверяется в 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 · Версия документации 1.0.0-beta© OxwaldLink · сгенерировано из Стандарта, исходников std и руководства