2012-06-15 12:24:12 -07:00
|
|
|
// error-pattern:assigning to immutable variable declared in an outer block
|
2012-01-09 16:12:37 -08:00
|
|
|
// Make sure that nesting a block within a fn@ doesn't let us
|
|
|
|
// mutate upvars from a fn@.
|
2012-01-23 14:59:00 -08:00
|
|
|
fn f2(x: fn()) { x(); }
|
2011-10-06 12:50:24 +02:00
|
|
|
|
2011-08-04 19:31:47 -07:00
|
|
|
fn main() {
|
|
|
|
let i = 0;
|
2012-01-09 16:12:37 -08:00
|
|
|
let ctr = fn@ () -> int { f2({|| i = i + 1; }); ret i; };
|
2011-12-22 17:53:53 -08:00
|
|
|
log(error, ctr());
|
|
|
|
log(error, ctr());
|
|
|
|
log(error, ctr());
|
|
|
|
log(error, ctr());
|
|
|
|
log(error, ctr());
|
|
|
|
log(error, i);
|
2011-08-04 19:31:47 -07:00
|
|
|
}
|