mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-17 05:25:37 +03:00
Add a test that lambdas can't deinitialize upvars
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
// error-pattern:assigning to upvar
|
||||
fn force(f: &block() -> int) -> int { ret f(); }
|
||||
fn main() {
|
||||
let x = 5;
|
||||
let f = lambda () -> int { let y = 6; x <- y; ret 7 };
|
||||
assert (force(f) == 7);
|
||||
log x;
|
||||
}
|
||||
Reference in New Issue
Block a user