rust/src/test/compile-fail/lambda-mutate.rs
2012-08-01 19:16:06 -07:00

13 lines
337 B
Rust

// error-pattern:assigning to captured outer variable in a heap closure
// Make sure we can't write to upvars from fn@s
fn main() {
let i = 0;
let ctr = fn@ () -> int { i = i + 1; return i; };
log(error, ctr());
log(error, ctr());
log(error, ctr());
log(error, ctr());
log(error, ctr());
log(error, i);
}