Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAsync Function Definitions: FormalParameters [?Await], contradicts with text #978
Comments
pushed a commit
to marjakh/ecma262
that referenced
this issue
Aug 17, 2017
pushed a commit
to marjakh/ecma262
that referenced
this issue
Aug 17, 2017
pushed a commit
to marjakh/ecma262
that referenced
this issue
Aug 17, 2017
mathiasbynens
referenced this issue
Aug 17, 2017
Merged
Normative: Fix [?Await] in async function FormalParameters (#978) #979
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
littledan
Aug 17, 2017
Member
The change seems to reflect the behavior of V8, ChakraCore, SpiderMonkey and JSC:
$ eshost -e "async function(await) {}"
#### jsc
SyntaxError: Can't use 'await' as a parameter name in an async function.
#### chakracore
SyntaxError: The use of a keyword for an identifier is invalid
#### spidermonkey
SyntaxError: missing formal parameter:
#### d8
SyntaxError: Unexpected reserved word
Should we give similar treatment to CoverCallExpressionAndAsyncArrowHead? It looks like that also takes Await as a parameter, but similarly, four implementations seem to consistently reject Await.
Since this is such consistent consensus among implementations, and the await parameter would be unusable if it were definable, and the patch also matches the grammar for single-parameter arrow functions (which ban async await => { /* ... */ } , I think we should definitely merge this patch.
|
The change seems to reflect the behavior of V8, ChakraCore, SpiderMonkey and JSC:
Should we give similar treatment to CoverCallExpressionAndAsyncArrowHead? It looks like that also takes Since this is such consistent consensus among implementations, and the |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
marjakh
Aug 18, 2017
Contributor
I don't think we should change this production:
CoverCallExpressionAndAsyncArrowHead[Yield, Await] :
MemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await]
because we want to allow await in the "not async arrow func" case.
The "Supplemental Syntax" below CoverCallExpressionAndAsyncArrowHead already says:
"When processing an instance of the production AsyncArrowFunction: CoverCallExpressionAndAsyncArrowHead [no LineTerminator here] => AsyncConciseBody the interpretation of CoverCallExpressionAndAsyncArrowHead is refined using the following grammar:
AsyncArrowHead :
async [no LineTerminator here] ArrowFormalParameters [~Yield, +Await]"
and that already forbids await there.
So I don't think anything related to CoverCallExpressionAndAsyncArrowHead needs to be changed.
|
I don't think we should change this production: CoverCallExpressionAndAsyncArrowHead[Yield, Await] : because we want to allow await in the "not async arrow func" case. The "Supplemental Syntax" below CoverCallExpressionAndAsyncArrowHead already says: "When processing an instance of the production AsyncArrowFunction: CoverCallExpressionAndAsyncArrowHead [no LineTerminator here] => AsyncConciseBody the interpretation of CoverCallExpressionAndAsyncArrowHead is refined using the following grammar: AsyncArrowHead : and that already forbids await there. So I don't think anything related to CoverCallExpressionAndAsyncArrowHead needs to be changed. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Oh I see, good. |
marjakh commentedAug 17, 2017
Link:
14.6 Async Function Definitions
In the AsyncFunctionDeclaration production, FormalParameters are parameterized with [~Yield, ?Await]: yield is allowed as an identifier and await is allowed as an identifier iff the parent production allows it (i.e., if the async function occurs at top level, await would be allowed as an identifier).
Note 1 says:
"When Script is the syntactic goal symbol, await may be parsed as an identifier when the [Await] parameter is absent. This includes the following contexts:
which contradicts with the productions.
The production probably should have FormalParameters parameterized with [~Yield, +Await].
In the AsyncFunctionExpression production, FormalParameters are parameterized with [~Yield, +Await] as expected.