Add a cleanup for copying closures. Closes #804.

This commit is contained in:
Michael Sullivan 2011-08-04 17:58:12 -07:00
parent 9a5e9806f3
commit 66a255ac92
2 changed files with 10 additions and 0 deletions

View File

@ -6387,6 +6387,9 @@ fn trans_closure(bcx_maybe: &option::t[@block_ctxt],
let closure = create_real_fn_pair(env.bcx, option::get(llfnty),
llfndecl, env.ptr);
if copying {
add_clean_temp(bcx, closure, node_id_type(cx.ccx, id))
}
some({fn_pair: closure, bcx: env.bcx})
}
_ { none }

View File

@ -0,0 +1,7 @@
// Make sure we don't leak lambdas in silly ways.
fn force(f: &fn()) { f() }
fn main() {
let x = 7;
lambda() { log_err x; };
force(lambda() { log_err x; });
}