mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-09 00:22:36 +02:00
When a for-of or for-await-of loop exits via break, return, throw, or continue-to-outer-loop, we now correctly call IteratorClose (or AsyncIteratorClose) to give the iterator a chance to clean up resources. This uses a synthetic FinallyContext that wraps the LHS assignment and loop body, reusing the existing try/finally completion record machinery. The ReturnToFinally boundary is placed between Break and Continue so that continue-to-same-loop bypasses the close (zero overhead on normal iteration) while all other abrupt exits route through the iterator close dispatch chain. for-in (enumerate) does not require iterator close per spec.
201 KiB
201 KiB