Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 09c4cfc7d73ceb6b56d2ad825740b2f67f1bbd10
      
https://github.com/WebKit/WebKit/commit/09c4cfc7d73ceb6b56d2ad825740b2f67f1bbd10
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-10-05 (Mon, 05 Oct 2026)

  Changed paths:
    A 
JSTests/stress/await-identifier-in-function-nested-in-async-function-parameters.js
    M Source/JavaScriptCore/parser/Parser.cpp

  Log Message:
  -----------
  [JSC] `await` should be an identifier in a non-async function nested in the 
parameters of an async function
https://bugs.webkit.org/show_bug.cgi?id=325954

Reviewed by Yusuke Suzuki.

JSC throws a SyntaxError when the body of a non-async function uses `await`
as an identifier, and that function is in the parameters of an async function:

    async function f(x = function () { var await; }) {}

FormalParameters of an async function are parsed with [+Await], but the body
of a nested non-async function is FunctionBody[~Yield, ~Await], so `await` is
an identifier there.

The parser clears ParserState::allowAwait while it parses a parameter list in
which `await` is reserved. A function nested in such a parameter list computes
allowAwait again for its own parameters, but its body was parsed with the value
of the enclosing parameter list. This patch sets allowAwait when parsing a
function body. Whether `await` is reserved in the body is decided by the scope
of the body.

Test: 
JSTests/stress/await-identifier-in-function-nested-in-async-function-parameters.js

* 
JSTests/stress/await-identifier-in-function-nested-in-async-function-parameters.js:
 Added.
(shouldBe):
(shouldThrowSyntaxError):
(const.functions.body):
(body):
(body.method):
(body.generator):
(body.get getter):
(body.set setter):
(body.):
(const.parameterLists.value.async f):
(const.parameterLists.value):
(value):
(prototype.value):
(async value.async f):
(async value):
(prototype.async value):
(value.async f):
(async f):
(prototype.shouldThrowSyntaxError.async f):
(prototype.shouldThrowSyntaxError):
(prototype.shouldBe.async f):
(prototype.shouldBe):
(prototype.shouldBe.let.object.async method):
(prototype.shouldBe.let.f):
(async f.):
(async f.let.g):
(let.AsyncFunction):
(async let):
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseFunctionBody):

Canonical link: https://commits.webkit.org/322703@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to