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

14 lines
352 B
Rust
Raw Normal View History

// error-pattern:assigning to immutable alias
// Make sure that nesting a block within a lambda doesn't let us
// mutate upvars from a lambda.
fn main() {
let i = 0;
let ctr = lambda () -> int { block () { i = i + 1; }(); ret i; };
log_err ctr();
log_err ctr();
log_err ctr();
log_err ctr();
log_err ctr();
log_err i;
}