Skip to content

fix: ensure scope.push register in anonymous fn#17504

Merged
JLHwung merged 1 commit intobabel:mainfrom
JLHwung:fix-scope-push-iife
Sep 5, 2025
Merged

fix: ensure scope.push register in anonymous fn#17504
JLHwung merged 1 commit intobabel:mainfrom
JLHwung:fix-scope-push-iife

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented Sep 5, 2025

Q                       A
Fixed Issues? scope.push may register binding to parameter when the function is a named function expression.
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Spot this issue when working on #17503. Previously we checked .name property, which should have been .id.

@JLHwung JLHwung added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Sep 5, 2025

function isAnonymousFunctionExpression(
path: NodePath,
): path is NodePath<t.FunctionExpression | t.ArrowFunctionExpression> {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The predicate here also converts NodePath<A> | NodePath<B> to NodePath<A | B> such that path.pushContainer can work. This is a bit unfortunate as we have already made it distributive.

@babel-bot
Copy link
Copy Markdown
Collaborator

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Sep 5, 2025

Open in StackBlitz

commit: 134a1e7

@JLHwung JLHwung merged commit 19c9126 into babel:main Sep 5, 2025
76 checks passed
@JLHwung JLHwung deleted the fix-scope-push-iife branch September 5, 2025 22:52
@github-actions github-actions Bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Dec 6, 2025
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Dec 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants