From b14032bbfa8d49f4a342c0fc88eb5c6ed8c43395 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 5 Jul 2023 14:07:20 +0200 Subject: [PATCH] LibJS/Bytecode: Leave `for in` and `for of` with right completion value 14 new passes on test262. :^) --- Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp index ec1ee2d2fc..348fcd9c9b 100644 --- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -2705,9 +2705,15 @@ static Bytecode::CodeGenerationErrorOr for_in_of_body_evaluation(Bytecode: // 1. Assert: iterationKind is iterate. // 2. Return ? IteratorClose(iteratorRecord, status). + generator.emit(js_undefined()); + // l. Let result be the result of evaluating stmt. TRY(body.generate_bytecode(generator)); + auto result_register = generator.allocate_register(); + if (!generator.is_current_block_terminated()) + generator.emit(result_register); + // m. Set the running execution context's LexicalEnvironment to oldEnv. if (has_lexical_binding) generator.end_variable_scope(); @@ -2730,6 +2736,7 @@ static Bytecode::CodeGenerationErrorOr for_in_of_body_evaluation(Bytecode: generator.emit().set_targets(Bytecode::Label { loop_update }, {}); generator.switch_to_basic_block(loop_end); + generator.emit(result_register); return {}; }