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

error ambiguous-embed

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

Имя продвигается из двух встроенных типов.

What it means#

When two embedded types both provide a field or method with the same name, using that name through the outer type is ambiguous (§4.7). The conflict is reported at the use, and disappears if the outer type defines the name itself or the use is qualified.

Example#

oxl✓ проверяется в CI
data Animal { name: str }
data Pet { name: str }
data Dog { embed Animal; embed Pet }

fn main() {
  let d = Dog{ Animal: Animal{ name: "a" }, Pet: Pet{ name: "p" } }
  print(d.name)      // <- ambiguous-embed
}
error
ambiguous-embed

How to fix#

oxl✓ проверяется в CI
data Animal { name: str }
data Pet { name: str }
data Dog { embed Animal; embed Pet }

fn main() {
  let d = Dog{ Animal: Animal{ name: "a" }, Pet: Pet{ name: "p" } }
  print(d.Animal.name)
}

Qualify the access with the embedded type (d.Animal.name), or declare the member in the outer type.

See also#

OxL 1.0.0-beta · Версия документации 1.0.0-beta© OxwaldLink · сгенерировано из Стандарта, исходников std и руководства