Files
ladybird/Tests/LibJS/Bytecode/input/for-of-iterator-close.js
Andreas Kling ecadf3ce21 LibJS: Inline AsyncIteratorClose with proper Await in for-await-of
The AsyncIteratorClose bytecode op calls async_iterator_close() which
uses synchronous await() internally. This spins the event loop while
execution contexts are on the stack, violating the microtask checkpoint
assertion in LibWeb.

Replace AsyncIteratorClose op emissions in for-await-of close handlers
with inline bytecode that uses the proper Await op, allowing the async
function to yield and resume naturally through the event loop.

For the non-throw path (break/return/continue-to-outer): emit
GetMethod, Call, Await, and ThrowIfNotObject inline.

For the throw path: wrap the close steps in an exception handler so
that any error from GetMethod/Call/Await is discarded and the original
exception is rethrown, per spec step 5.
2026-02-12 11:37:43 +01:00

21 lines
345 B
JavaScript

function forOfBreak() {
for (const x of [1, 2, 3]) {
if (x === 2) break;
}
}
forOfBreak();
function forOfReturn() {
for (const x of [1, 2, 3]) {
return x;
}
}
forOfReturn();
async function forAwaitOfBreak(iter) {
for await (const x of iter) {
if (x === 2) break;
}
}
forAwaitOfBreak([1, 2, 3]);