Repository navigation
fix(regenerator): throw on using declarations - #18624
Conversation
using declarationsusing declarations
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/63399 |
using declarationsusing declarations
|
commit: |
|
@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") { |
There was a problem hiding this comment.
Could we instead list what var kinds are supported? It seems safer and more future-proof.
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.
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
b65c2b8 to
7033901
Compare
7033901 to
02f73bd
Compare
02f73bd to
7033901
Compare
|
Backported to 7.x in #18650. |
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