rust/src/test/compile-fail/lambda-mutate.rs

13 lines
337 B
Rust
Raw Normal View History

// 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;
2012-08-01 19:30:05 -05:00
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);
}