Add a test that lambdas can't deinitialize upvars
This commit is contained in:
parent
e824775d53
commit
ec763bba9c
8
src/test/compile-fail/block-deinitializes-upvar.rs
Normal file
8
src/test/compile-fail/block-deinitializes-upvar.rs
Normal file
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user