Repository navigation
fix(parser): allow lone yield before in in an Annex B for-in init - #18444
Merged
JLHwung merged 2 commits intoOct 31, 2026
Merged
Conversation
Collaborator
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/62863 |
|
commit: |
JLHwung
force-pushed
the
fix-parser-yield-before-in-for-in-initializer
branch
from
October 29, 2026 14:47
2d26c14 to
9203205
Compare
nicolo-ribaudo
approved these changes
Oct 29, 2026
nicolo-ribaudo
left a comment
Member
There was a problem hiding this comment.
Can you add a test case where it still errors, e.g.
function* fn() {
for (var a = (yield in x) in y);
}
JLHwung
force-pushed
the
fix-parser-yield-before-in-for-in-initializer
branch
from
October 29, 2026 15:25
aba6933 to
938bdfb
Compare
In sloppy mode, the generator code `for (var x = yield in z)` is valid (B.3.5): the initializer is an `AssignmentExpression[~In]`, `in` cannot start an AssignmentExpression, so the `yield` has no operand and the `in` belongs to the for-in head. `parseYield` only treated the tokens that can follow an `AssignmentExpression[+In]` as terminators, so it tried to parse `in` as the operand and failed. Every other `yield in` form still errors because `in` is not accepted after a YieldExpression anywhere else. Assisted-by: Claude Fable 5.1 <[email protected]>
JLHwung
force-pushed
the
fix-parser-yield-before-in-for-in-initializer
branch
from
October 31, 2026 17:48
938bdfb to
84394a7
Compare
liuxingbaoyu
approved these changes
Oct 31, 2026
Collaborator
|
Backported to 7.x in #18485. |
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.
function* g() { for (var x = yield in z); }whensourceTypeisscriptandannexBparser option is enabled.In this PR we fixed a spec compliance issue reported by Claude Fable: In Annex B.3.5, the following production is allowed in sloppy mode:
The Initializer is
AssignmentExpression[~In], soinafteryieldbelongs to the for-in head. However,parseYieldonly treated the tokens that can follow anAssignmentExpression[+In]as terminators, so it tried to parseinas the operand and then failed.Assisted-by: Claude Fable 5.1