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
A tour of VxThe chapter covering the rule this code enforces.
All diagnosticsEvery code the compiler can emit, grouped by stage.
E3035A method name that more than one
impl block defines for the same type. The impls are kept in a hash map, so which body a call reached used to change from one run of the compiler to the next; refusing the call is the only answer that is the same twice.
E3038type Item = .. in an impl whose trait declares no Item. Usually a misspelling: nothing reads the binding, so it would go on meaning nothing, in silence.