Compare commits

..

1 Commits

Author SHA1 Message Date
David Mak e07cc64a95 core: Fix restoration of loop target in try statement
I am not sure why this occurs either, it only appears that after the
assignment, `old_loop_target` and `loop_target` are both referencing the
same variable, causing the next line to set both variables as None.
2023-09-25 11:54:33 +08:00
1 changed files with 7 additions and 2 deletions

View File

@ -789,7 +789,10 @@ pub fn gen_try<'ctx, 'a, G: CodeGenerator>(
ctx.outer_catch_clauses = old_clauses;
ctx.unwind_target = old_unwind;
ctx.return_target = old_return;
ctx.loop_target = old_loop_target.or(ctx.loop_target).take();
if let Some(old_loop_target) = old_loop_target {
ctx.loop_target.replace(old_loop_target);
}
old_loop_target = None;
let old_unwind = if !finalbody.is_empty() {
let final_landingpad = ctx.ctx.append_basic_block(current_fun, "try.catch.final");
@ -910,7 +913,9 @@ pub fn gen_try<'ctx, 'a, G: CodeGenerator>(
}
ctx.unwind_target = old_unwind;
ctx.loop_target = old_loop_target.or(ctx.loop_target).take();
if let Some(old_loop_target) = old_loop_target {
ctx.loop_target.replace(old_loop_target);
}
ctx.return_target = old_return;
ctx.builder.position_at_end(landingpad);