OxL Reference

error ambiguous-embed

error Standard: [§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✓ checked in 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✓ checked in 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 · Documentation version 1.0.0-beta© OxwaldLink · generated from the Standard, the std sources and the guides