mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibJS/Bytecode: Let var
without initializer codegen to nothing
Otherwise we incorrectly overwrite the binding with `undefined` at the point where the `var` statement is. Fixes 9 test262 tests. :^)
This commit is contained in:
parent
743943a042
commit
eee4b6eca7
Notes:
sideshowbarker
2024-07-17 16:42:19 +09:00
Author: https://github.com/awesomekling
Commit: eee4b6eca7
Pull-request: https://github.com/SerenityOS/serenity/pull/19439
1 changed files with 5 additions and 3 deletions
|
@ -1267,11 +1267,13 @@ static Bytecode::CodeGenerationErrorOr<void> assign_accumulator_to_variable_decl
|
|||
Bytecode::CodeGenerationErrorOr<void> VariableDeclaration::generate_bytecode(Bytecode::Generator& generator) const
|
||||
{
|
||||
for (auto& declarator : m_declarations) {
|
||||
if (declarator->init())
|
||||
if (declarator->init()) {
|
||||
TRY(declarator->init()->generate_bytecode(generator));
|
||||
else
|
||||
TRY(assign_accumulator_to_variable_declarator(generator, declarator, *this));
|
||||
} else if (m_declaration_kind != DeclarationKind::Var) {
|
||||
generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
|
||||
TRY(assign_accumulator_to_variable_declarator(generator, declarator, *this));
|
||||
TRY(assign_accumulator_to_variable_declarator(generator, declarator, *this));
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue