docs

You are reading the docs for v0.1.0. Nabi 0.1.0 is no longer supported. Latest release: v0.1.3 →

#E0087: ambiguous associated item

Several traits, impls or bounds give a method, associated type or constant of this name, so T::name is unclear. Name the trait: <T as Trait>::name, or call the method as Trait::name(x).

nabi
trait A { const N: i32; }
trait B { const N: i32; }
struct S {}
impl A for S { const N: i32 = 1; }
impl B for S { const N: i32 = 2; }

println(f"{S::N}");
error[E0087]: associated const `N` of `S` is ambiguous: `A` and `B` define it - name the trait (`<T as Tr>::N`)
  --> main.nabi:7:12
   |
 7 | println(f"{S::N}");
   |            ^^^^

Name the trait:

nabi
trait A { const N: i32; }
trait B { const N: i32; }
struct S {}
impl A for S { const N: i32 = 1; }
impl B for S { const N: i32 = 2; }

println(f"{<S as B>::N}");
2

Related: E0031 ambiguous name, E0075 conflicting implementations

Found a mistake? Edit this page on GitHub. Last updated