rust/src/test/compile-fail/autoderef-full-lval.rs
Michael Sullivan 0340f32748 Eliminate autoderef on binops and unary negation.
Autoderef on binops is basically unused, kind of silly, and
complicates typechecking. There were only three instances of it in the
compiler and the test drivers, two of which were of the form "*foo =
foo + 1", which should be written as "*foo += 1" anyways.
2011-08-12 18:28:03 -07:00

18 lines
408 B
Rust

// error-pattern: binary operation + cannot be applied to type
type clam = {x: @int, y: @int};
type fish = {a: @int};
fn main() {
let a: clam = {x: @1, y: @2};
let b: clam = {x: @10, y: @20};
let z: int = a.x + b.y;
log z;
assert (z == 21);
let forty: fish = {a: @40};
let two: fish = {a: @2};
let answer: int = forty.a + two.a;
log answer;
assert (answer == 42);
}