Skip to content

Fix(parser): async x => {} must be in leading pos#17839

Merged
JLHwung merged 2 commits intobabel:mainfrom
JLHwung:fix-async-single-name-arrow-parse
Feb 27, 2026
Merged

Fix(parser): async x => {} must be in leading pos#17839
JLHwung merged 2 commits intobabel:mainfrom
JLHwung:fix-async-single-name-arrow-parse

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented Feb 27, 2026

Q                       A
Fixed Issues? #17838 (comment), issue introduced in #11871
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

In this PR we forbid the single name async arrow, e.g. async x => {} forming in the unary argument, binary expression, class heritage and legacy decorators. Previously such productions were accepted by the parser but they are not allowed in the spec.

@JLHwung JLHwung added pkg: parser PR: Spec Compliance (next major) 👓 A type of pull request used for our changelog categories for next major release 7.x: needs backport labels Feb 27, 2026
@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented Feb 27, 2026

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

Copy link
Copy Markdown
Member

@liuxingbaoyu liuxingbaoyu left a comment

Choose a reason for hiding this comment

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

I'm surprised we passed all the test262 syntax tests in the past. :)

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Feb 27, 2026

Open in StackBlitz

commit: 1f6c840

@JLHwung
Copy link
Copy Markdown
Contributor Author

JLHwung commented Feb 27, 2026

Yeah, apparently 1 + async x () => {} and other new cases are not in the test262 syntax tests, otherwise we would have detected this bug long before. This issue is introduced in #11871, dated back to Babel 7.12.0. I feel sorry about that.

@liuxingbaoyu
Copy link
Copy Markdown
Member

No problem, this shouldn't affect anyone. :)

@JLHwung JLHwung force-pushed the fix-async-single-name-arrow-parse branch from 2d9cea7 to caa406b Compare February 27, 2026 18:29
@JLHwung JLHwung force-pushed the fix-async-single-name-arrow-parse branch from caa406b to 1f6c840 Compare February 27, 2026 20:19
@JLHwung JLHwung merged commit 6f16f12 into babel:main Feb 27, 2026
54 checks passed
@JLHwung JLHwung deleted the fix-async-single-name-arrow-parse branch February 27, 2026 20:40
@nicolo-ribaudo nicolo-ribaudo added the PR: Spec Compliance 👓 A type of pull request used for our changelog categories label Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: parser PR: Spec Compliance 👓 A type of pull request used for our changelog categories PR: Spec Compliance (next major) 👓 A type of pull request used for our changelog categories for next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants