rust/src/test/run-pass/obj-self-3.rs
Marijn Haverbeke 1a68a98824 Disallow writing to function arguments again
Remove implicit copying hack.

Closes #1118
2011-11-03 10:57:54 +01:00

18 lines
359 B
Rust

fn main() {
obj foo() {
fn m1(i: int) -> int { let i = i + 1; ret i; }
fn m2(i: int) -> int { ret self.m1(i); }
fn m3(i: int) -> int { let i = i + 1; ret self.m1(i); }
}
let a = foo();
let i: int = 0;
i = a.m1(i);
assert (i == 1);
i = a.m2(i);
assert (i == 2);
i = a.m3(i);
assert (i == 4);
}