diff --git a/src/test/compile-fail/block-deinitializes-upvar.rs b/src/test/compile-fail/block-deinitializes-upvar.rs new file mode 100644 index 00000000000..da5922036a7 --- /dev/null +++ b/src/test/compile-fail/block-deinitializes-upvar.rs @@ -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; +}