fix(transpiler): keep for-loop counters raw in switch-arm return arguments - #318
Open
yusufcansehirli wants to merge 1 commit into
Open
yusufcansehirli wants to merge 1 commit into
yusufcansehirli wants to merge 1 commit into
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
…get(i,0)++ codegen)
yusufcansehirli
force-pushed
the
fix/for-loop-counter-in-return-argument
branch
from
September 18, 2026 21:20
9456080 to
f283b4c
Compare
Author
|
I have read the CLA Document and I hereby sign the CLA |
alaa-eddine
added a commit
to LuxAlgo/cla-signatures
that referenced
this pull request
Sep 18, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
transpile()can emit invalid JavaScript for aforloop whose counter is reached through the complex-return-argument walker intransformReturnStatement():$.get(iR, 0)++is a postfix update on a call expression, which is invalid JavaScript —SyntaxError: Invalid left-hand side expression in postfix operationwhen the generated function is constructed.The path is reached when a function's last statement is a bare
switch: the implicit return argument is walked by the return-argument transformer, and the default traversal descends into the arm IIFEs and theirForStatementheaders.Repro (12 lines):
Fix
ForStatement() {}no-op visitor to the complex return-argument walker so for-headers are never descended into (the loop's declaration/test/update/body are handled by the statement machinery when the enclosing function is transformed).Identifiervisitor.Test
tests/transpiler/for-loop-counter-return-argument.test.ts— minimal-repro regression test. Before the fix it fails (generated code contains$.get(iR, 0)++/--); after the fix the counter stays a raw JS local and the generated function constructs and runs.Verification
tests/transpiler/— 33 files / 504 tests pass.pagination,request-cross-tf) are flaky and also fail intermittently on unpatchedmainin this environment — unrelated pre-existing flakiness.