GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(regenerator): catch-pattern support review issues by JLHwung · Pull Request #18763 · babel/babel

Conversation

@JLHwung

@JLHwung JLHwung commented Nov 28, 2026

Copy link
Copy Markdown
Contributor
Q                       A
Fixed Issues? #18732 (review)
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
Need backport? No
License MIT

In this PR we fix the review issues on #18732:

These examples seem somewhat extreme, so they do not block this PR.

Case 1

function* g(obj = { [arguments.length]() {} }) {
  yield Object.keys(obj);
}

console.log(g().next().value);
// main → ["0"]
// PR   → ReferenceError: _args is not defined

The root cause of case 1 is that the arguments binding in parameters are accidentally renamed, while they should have been renamed in the function body.

Case 2

function* g() {
  for (let arguments = 1; arguments < 3; arguments++) {
    yield arguments;
  }
}

console.log([...g()]);
// main → [1, 2]
// PR   → [1]

The root cause of case 2 is that the arguments binding end up in the inner function. We should rename it before the hoist.

Case 3

function* g() {
  try {
    yield 1;
  } catch ([__proto__]) {
    yield { __proto__, __proto__: null };
  }
}

console.log(g().next().value);
// main → 1
// PR   → SyntaxError: Duplicate __proto__ fields are not allowed in object literals

The root casue of case 3 is a renamer bug. This is now fixed in babel-traverse.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
JLHwung added 3 commits November 27, 2026 21:52
@JLHwung
fix(traverse): keep renamed shorthand __proto__ an own property
7c926d3
Renaming the binding of `{ __proto__ }` turned it into
`{ __proto__: _t }`, which sets the prototype instead of defining an own
property, and is a syntax error next to another `__proto__: value`.
The key is now `["__proto__"]` in object literals.

Assisted-by: Claude Opus 5.5
@JLHwung
fix(plugin-transform-regenerator): handle block-scoped arguments bi…
f2a9f92
…ndings

Block-scoped bindings named `arguments`, such as
`for (let arguments = 1; ...)`, were left alone and then hoisted into
the inner function, where `arguments` is that function's own. They are
now renamed before hoisting, so every remaining `arguments` reference
in the body is the generator's own and is replaced with `_args`.

The `this`/`arguments` detection no longer visits the parameters,
which stay in the outer function. `function* g(a = arguments.length)`
used to reference `_args` before it was declared, and computed keys of
methods in parameter defaults did too.

Assisted-by: Claude Opus 5.5
@JLHwung
refactor(plugin-transform-regenerator): simplify catch and `arguments…
cf37821
…` renaming

`renameArgumentsBindingsVisitor` starts from the children of the body,
so every scope it visits differs from the function scope and the check
against it was always true. The catch clause code now reads the
parameter, scope and body from a single `handler` path instead of three
separate lookups with casts.

Assisted-by: Claude Opus 5.5
@JLHwung
JLHwung requested a review from liuxingbaoyu November 28, 2026 03:11
@JLHwung
JLHwung added this pull request to stack #18587 November 28, 2026 03:11
@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories 7.x: needs backport labels Nov 28, 2026
@babel-bot

babel-bot commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/63970

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pkg-pr-new

pkg-pr-new Bot commented Nov 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: cf37821

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JLHwung JLHwung mentioned this pull request Nov 28, 2026
fix(regenerator): support destructuring catch parameters #18732
Open
liuxingbaoyu
liuxingbaoyu approved these changes Nov 28, 2026
View reviewed changes

@liuxingbaoyu liuxingbaoyu left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@liuxingbaoyu liuxingbaoyu liuxingbaoyu approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

7.x: needs backport PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@JLHwung @babel-bot @liuxingbaoyu
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.