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

13 lines
328 B
Rust
Raw Normal View History

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