mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 15:28:55 +00: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
Notes:
github-actions[bot]
2025-03-20 23:59:34 +00:00
Author: https://github.com/awesomekling
Commit: b971e1ece0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4027
1 changed files with 0 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue