Description
Two interfaces may be declared in the same scope with same-named methods. This leads to problems when a type implements both interfaces:
iface A { fn foo() -> bool; }
iface B { fn foo() -> int; }
// These compile without warnings
fn aa<T:A B>(x: T) -> bool { x.foo() }
fn bb<T:B A>(x: T) -> int { x.foo() }
// These don't compile, due to type error
fn ab<T:A B>(x: T) -> int { x.foo() }
fn ba<T:B A>(x: T) -> bool { x.foo() }
It appears that which method "x.foo()" resolves to depends upon what order the bounds on x's type are declared in. The compiler does catch this ambiguity when we use a specific type rather than quantifying:
impl of A for int { fn foo() -> bool { self > 0 } }
impl of B for int { fn foo() -> int { self } }
fn foo(x: int) -> bool { x.foo() }
The above results in an "error: multiple applicable methods in scope". At the very least this same message should be produced in the first example for all functions (aa,ab,bb,ba).
I would argue that defining two interfaces with same-named methods in the same scope should itself be an error, for the same reason that defining two same-named functions in the same scope is an error: it produces inevitable and irresolvable ambiguity.