Skip to content

Commit

Permalink
Add missing environment creation in initial iteration of for loop (#3751
Browse files Browse the repository at this point in the history
)
  • Loading branch information
raskad committed Mar 25, 2024
1 parent d3e5395 commit 7987fd8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/engine/src/bytecompiler/statement/loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ impl ByteCompiler<'_> {
}

self.push_empty_loop_jump_control(use_expr);

if let Some((let_binding_indices, env_index)) = &let_binding_indices {
for index in let_binding_indices {
self.emit_with_varying_operand(Opcode::GetName, *index);
}

self.emit_opcode(Opcode::PopEnvironment);
self.emit_with_varying_operand(Opcode::PushDeclarativeEnvironment, *env_index);

for index in let_binding_indices.iter().rev() {
self.emit_with_varying_operand(Opcode::PutLexicalValue, *index);
}
}

let initial_jump = self.jump();
let start_address = self.next_opcode_location();

Expand Down

0 comments on commit 7987fd8

Please sign in to comment.