On 14/11/13 14:50, Tommi wrote:
let mut n = 11;
let p: &int = &123;

p + n; // OK
n + p; // error: mismatched types: expected `int` but found `&int`

Shouldn't this error be considered a compiler-bug? The Add trait says '&' for 
rhs after all:
fn add(&self, rhs: &RHS) -> Result;

-Tommi

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

This is https://github.com/mozilla/rust/issues/8895 . I believe it is caused by the implementation details of the overloaded-operator desugaring (a + b is equivalent to `a.add(&b)`, so auto-deref allows for `a: &T` with `b: T`), I personally think the more sensible resolution would be for `p + n` to be disallowed as well as `n + p`.

Huon
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to