mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 01:08:11 +00:00
LibJS: Generate update Jump in for/in/of only if block is not terminated
The body of for/in/of can contain an unconditional block terminator (e.g. return, throw), so we have to check for that before generating the Jump to the loop update block.
This commit is contained in:
parent
741745baab
commit
88901182b8
1 changed files with 5 additions and 1 deletions
|
@ -1999,7 +1999,11 @@ static Bytecode::CodeGenerationErrorOr<void> for_in_of_body_evaluation(Bytecode:
|
||||||
// 3. If iteratorKind is async, return ? AsyncIteratorClose(iteratorRecord, status).
|
// 3. If iteratorKind is async, return ? AsyncIteratorClose(iteratorRecord, status).
|
||||||
// 4. Return ? IteratorClose(iteratorRecord, status).
|
// 4. Return ? IteratorClose(iteratorRecord, status).
|
||||||
// o. If result.[[Value]] is not empty, set V to result.[[Value]].
|
// o. If result.[[Value]] is not empty, set V to result.[[Value]].
|
||||||
generator.emit<Bytecode::Op::Jump>().set_targets(Bytecode::Label { loop_update }, {});
|
|
||||||
|
// The body can contain an unconditional block terminator (e.g. return, throw), so we have to check for that before generating the Jump.
|
||||||
|
if (!generator.is_current_block_terminated())
|
||||||
|
generator.emit<Bytecode::Op::Jump>().set_targets(Bytecode::Label { loop_update }, {});
|
||||||
|
|
||||||
generator.switch_to_basic_block(loop_end);
|
generator.switch_to_basic_block(loop_end);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue