Repository navigation
fix(regenerator): throw on using declarations - #18624
Merged
Merged
Conversation
using declarationsusing declarations
Collaborator
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/63399 |
using declarationsusing declarations
|
commit: |
liuxingbaoyu
approved these changes
Nov 16, 2026
Contributor
Author
|
@liuxingbaoyu This is a stack PR, could you review the previous ones? Although they are technically not dependent on each other, I use this stack to track a list of similar PRs. This series is to fix issues that an plugin for older language feature does not correctly pass through or throw on the unsupported new syntax. |
| function varDeclToExpr(path: NodePath, includeIdentifiers: boolean) { | ||
| const vdec = path.node; | ||
| t.assertVariableDeclaration(vdec); | ||
| if (vdec.kind === "using" || vdec.kind === "await using") { |
Member
There was a problem hiding this comment.
Could we instead list what var kinds are supported? It seems safer and more future-proof.
Contributor
Author
There was a problem hiding this comment.
Good idea. I pushed a new commit and now it will throw if there are var kinds other than var, let and const.
nicolo-ribaudo
approved these changes
Nov 16, 2026
JLHwung
commented
Nov 16, 2026
JLHwung
force-pushed
the
jlhwung/fix-regenerator-using-declaration
branch
from
November 16, 2026 21:21
d39d34e to
b65c2b8
Compare
export * as ns from "mod" with { type: "json" }
was compiled to an import declaration without the attributes, they are now preserved and cloned if necessary.
Assisted-by: Claude Fable 5.2
export default m from "mod" with { type: "json" }
was compiled to an export declaration without the attributes, they are now cloned.
Assisted-by: Claude Fable 5.2
`{ __proto__() {}, __proto__: p }` is not a duplicate: the second property sets the prototype and does not define a property.
Previously the second property was rewritten to `["__proto__"]: p`, which defines an own property named "__proto__" and leaves the prototype untouched.
Assisted-by: Claude Fable 5.2
…a proto setter
ES5 engines count `__proto__: value` as a data property named "__proto__"
in the duplicate property checks, so `{ get __proto__() {}, __proto__: p }`
is a SyntaxError there even in sloppy mode (tested on V8 3.14 and 3.28).
When an object literal has a `__proto__: value` property, every other
non-computed property named "__proto__" is now made computed, whatever
the order, so that the proto setter keeps setting the prototype.
Assisted-by: Claude Opus 5.5
The regenerator transform hoists every variable declaration of the function as a `var`. A `using` or `await using` declaration became a plain assignment, so its resource was never disposed and no error was reported. It now throws and points to the explicit resource management transform, which compiles these declarations before regenerator sees them when both plugins are enabled. Assisted-by: Claude Fable 5.2
JLHwung
force-pushed
the
jlhwung/fix-regenerator-using-declaration
branch
from
November 16, 2026 21:25
b65c2b8 to
7033901
Compare
nicolo-ribaudo
force-pushed
the
jlhwung/fix-regenerator-using-declaration
branch
from
November 17, 2026 12:13
7033901 to
02f73bd
Compare
Base automatically changed from
jlhwung/fix-duplicate-keys-proto-setter
to
main
November 17, 2026 14:54
JLHwung
force-pushed
the
jlhwung/fix-regenerator-using-declaration
branch
from
November 17, 2026 15:12
02f73bd to
7033901
Compare
Collaborator
|
Backported to 7.x in #18650. |
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.
In this PR we fix an issue reported by Claude Fable: The regenerator transform hoists every variable declaration of the function as a
var. Ausingorawait usingdeclaration became a plain assignment, so its resource was never disposed and no error was reported.In this PR we make this case throw and point to the explicit resource management transform, rather than silently generated incorrect JS codes.
Assisted-by: Claude Fable 5.2