mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibJS: Mark locals as outside TDZ immediately after initializing
This avoids emitting TDZ checks for multiple bindings declared and
referenced within one variable declaration, i.e:
var foo = 0, bar = foo;
In the above case, we'd emit an unnecessary TDZ check for the second
reference to `foo`.
This commit is contained in:
parent
01031bcccb
commit
b971e1ece0
|
|
@ -1616,9 +1616,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> VariableDeclaration::ge
|
|||
} else if (m_declaration_kind != DeclarationKind::Var) {
|
||||
(void)TRY(assign_value_to_variable_declarator(generator, declarator, *this, generator.add_constant(js_undefined())));
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& declarator : m_declarations) {
|
||||
if (auto const* identifier = declarator->target().get_pointer<NonnullRefPtr<Identifier const>>()) {
|
||||
if ((*identifier)->is_local()) {
|
||||
generator.set_local_initialized((*identifier)->local_variable_index());
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user