Skip to content

fix(parser): reject await in the concise body of a non-async arrow in module code - #673

Merged
3cp merged 1 commit into
meriyah:mainfrom
lprnmns:fix/await-in-concise-arrow-body
Oct 28, 2026
Merged

3cp merged 1 commit into
meriyah:mainfrom
lprnmns:fix/await-in-concise-arrow-body

Conversation

@lprnmns

@lprnmns lprnmns commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

In module code, meriyah accepted await used as an expression in the concise body of a non-async arrow function:

// sourceType: 'module'
x => await x;
f(b => await + x);
`${b => await b}`;

An arrow's concise body is ConciseBody[~Await] for non-async arrows, so await there is neither an AwaitExpression nor (in module code) a valid identifier — these are early errors. acorn rejects all three. The block-body form (x => { await x }) was already rejected, because the function body parser clears Context.InGlobal; the concise-body path kept it, so top-level-await handling leaked into the arrow.

The fix adds Context.InGlobal to the flags cleared in parseArrowFunctionExpression, so both body forms behave the same.

Tests: three new fail cases in test/parser/expressions/arrow.ts (they pass parsing without the fix). The full suite (92,032 tests, rebased on main) and npm run lint pass.

@pkg-pr-new

pkg-pr-new Bot commented Oct 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/meriyah@673

commit: f88d603

@3cp 3cp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thx!

@3cp
3cp merged commit 43449ea into meriyah:main Oct 28, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants