Skip to content

Commit

Permalink
Fix var declaration deleted binding locator (#3387)
Browse files Browse the repository at this point in the history
  • Loading branch information
raskad authored Oct 16, 2023
1 parent 9bb3bea commit 9030417
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion boa_engine/src/bytecompiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1090,8 +1090,11 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> {
match variable.binding() {
Binding::Identifier(ident) => {
if let Some(expr) = variable.init() {
let binding = self.lexical_environment.get_identifier_reference(*ident);
let index = self.get_or_insert_binding(binding.locator());
self.emit_with_varying_operand(Opcode::GetLocator, index);
self.compile_expr(expr, true);
self.emit_binding(BindingOpcode::InitVar, *ident);
self.emit_opcode(Opcode::SetNameByLocator);
} else {
self.emit_binding(BindingOpcode::Var, *ident);
}
Expand Down

0 comments on commit 9030417

Please sign in to comment.