diff --git a/boa_engine/src/bytecompiler.rs b/boa_engine/src/bytecompiler.rs index 3708c1bd81..88ee542b21 100644 --- a/boa_engine/src/bytecompiler.rs +++ b/boa_engine/src/bytecompiler.rs @@ -1472,11 +1472,10 @@ impl<'b> ByteCompiler<'b> { self.compile_stmt(do_while.body(), false)?; self.emit(Opcode::Jump, &[condition_label_address]); + self.patch_jump(exit); self.pop_loop_control_info(); self.emit_opcode(Opcode::LoopEnd); - - self.patch_jump(exit); } Node::Continue(node) => { let next = self.next_opcode_location(); diff --git a/boa_engine/src/tests.rs b/boa_engine/src/tests.rs index 5500d3d34e..e5e8d9dcbe 100644 --- a/boa_engine/src/tests.rs +++ b/boa_engine/src/tests.rs @@ -381,6 +381,21 @@ fn do_while_post_inc() { assert_eq!(&exec(with_post_incrementors), "11"); } +#[test] +fn do_while_in_block() { + let in_block = r#" + { + var i = 0; + do { + i += 1; + } + while(false); + i; + } + "#; + assert_eq!(&exec(in_block), "1"); +} + #[test] fn for_loop() { let simple = r#"