Repository navigation
fix: reject untranspiled ??, &&=, ||=, ??= before yield expression - #18679
Merged
Merged
Conversation
Collaborator
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/63748 |
|
commit: |
nicolo-ribaudo
approved these changes
Nov 22, 2026
JLHwung
force-pushed
the
jlhwung/fix-regenerator-logical-assignment
branch
from
November 23, 2026 13:59
6604c2c to
358c0fa
Compare
JLHwung
force-pushed
the
jlhwung/fix-regenerator-logical-assignment
branch
6 times, most recently
from
November 23, 2026 19:35
b9fc44d to
d7bf5d1
Compare
Base automatically changed from
jlhwung/fix-proto-to-assign-non-setters
to
main
November 24, 2026 13:07
…||` and `&&` When the value of `(yield a) || b` or `(yield a) && b` is used, the temporary variable holding the left operand was used both in the jump test and in the result, reusing the same AST node. It is now cloned. Assisted-by: Claude Opus 5.5
…??` with `yield` `a ||= yield b` was compiled like an arithmetic compound assignment: the right-hand side was always evaluated and the target always assigned. `a ?? (yield b)` failed with an assertion error. Both now throw, asking for @babel/plugin-transform-logical-assignment-operators or @babel/plugin-transform-nullish-coalescing-operator. Those plugins lower the expressions before the regenerator transform reaches them, whatever the plugin order, and every target without generators needs them anyway. Assisted-by: Claude Fable 5.2 Assisted-by: Claude Opus 5.5
JLHwung
force-pushed
the
jlhwung/fix-regenerator-logical-assignment
branch
from
November 24, 2026 13:07
d7bf5d1 to
dd6dcfb
Compare
Collaborator
|
Backported to 7.x in #18711. |
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.
a ||= yield balways evaluatebCurrently, the regenerator on main transforms
to
where
bis always evaluated and the||=is applied after the generator resumes. The same issue also happens for nullish coalescing as well.Since the generator feature predates logical assignment and nullish coalescing by a couple of years, I think it is fair that the regenerator transform does not support lowering these features. In this PR we throw a compilation error if the regenerator transform is enabled but plugins for those features are not. This is done in the second commit.
An alternative solution is to piggyback the lowering of these two features here, which I don't think is very sustainable since in the long term we will have to cherry pick more features here.
We also fix an AST node reuse issue during the review session, it is fixed in the first commit.