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 {}; }