Return a better result from blocks. Closes issue #377

Blocks return in a copy of the result of their ending expression, not the
direct result of the ending expression, as that may be a local variable which
gets zeroed by drop_slot.
This commit is contained in:
Brian Anderson 2011-05-15 01:51:31 -04:00
parent 4539b3f6ab
commit fbfd8552ab
2 changed files with 22 additions and 0 deletions

View file

@ -6252,6 +6252,9 @@ fn trans_block(&@block_ctxt cx, &ast::block b) -> result {
auto cleanup = bind drop_hoisted_ty(_, res_alloca.val,
r_ty);
find_outer_scope_cx(bcx).cleanups += [clean(cleanup)];
r = res(bcx, load_if_immediate(bcx,
res_alloca.val, r_ty));
}
}
}