E3037

E3037 — An impl of a trait that declares an associated type does not bind it. The trait's signatures are written against Self::Item, so with no binding there is nothing to put in their place, and the method's type becomes whatever the impl happened to write.

What the compiler reports

E3037 … does not bind the associated type 'Item'

The fragments the test suite holds the compiler to. An ellipsis marks text the test does not constrain; the emitted message also carries a source location.

A program that triggers it

trait Counter {
  type Item;
  fn next(self : Self) -> Self::Item;
}

impl Counter for i32 {
  fn next(self : i32) -> i64 {
    return 7;
  }
}

fn main() -> i32 {
  let a : i32 = 1;
  print(a.next());
  return 0;
}

// Nothing downstream can catch this: the binding is substituted into the impl's signatures
// before name resolution, so a missing one leaves the impl's own `-> i64` to be trusted.

From tests/frontend/fail/associated_type_not_bound.vx, which asserts this diagnostic on every commit.

Related