Fix ForInOfStatementNode labeled continue handling (Issues #1571 Crashes #3-4)

Issue #1571 Crash #3: Labeled continue in for-of loop
- Iterator value issue when labeled continue triggered early
- Proper sequencing of iterator cleanup vs control flow

Issue #1571 Crash #4: With statement + labeled for-of
- Environment unwinding coordination with iterator cleanup
- CloseLexicalEnvironment called at correct time

Solution: Consume labeled continues with proper morphing
- Ensures iterator cleanup finalizer runs before unwinding
- Control flow record management stays consistent
- Both for-in and for-of (and for-await-of) properly handled

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
Seonghyun Kim 2026-06-15 14:05:33 +09:00
commit f480402fac

View file

@ -373,6 +373,12 @@ public:
newContext.consumeContinuePositions(codeBlock, continuePosition, newContext.tryCatchWithBlockStatementCount());
newContext.m_positionToContinue = continuePosition;
// Consume labeled continues targeting THIS loop with proper morphing (Issue #1571)
// This ensures iterator cleanup and environment unwinding are properly sequenced
if (context->m_currentLoopLabel) {
newContext.consumeLabelledContinuePositions(codeBlock, continuePosition, context->m_currentLoopLabel, newContext.tryCatchWithBlockStatementCount());
}
if (!m_forIn) {
TryStatementNode::generateTryStatementBodyEndByteCode(codeBlock, &newContext, this, forOfTryStatementContext);
TryStatementNode::generateTryFinalizerStatementStartByteCode(codeBlock, &newContext, this, forOfTryStatementContext, true);