Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Add cover grammar for 'await using' #15

Merged
merged 9 commits into from
Apr 11, 2023
Merged

Add cover grammar for 'await using' #15

merged 9 commits into from
Apr 11, 2023

Conversation

rbuckton
Copy link
Collaborator

@rbuckton rbuckton commented Mar 22, 2023

Adds a cover grammar for await using.

Fixes #12

@github-actions
Copy link

A preview of this PR can be found at https://tc39.es/proposal-async-explicit-resource-management/pr/15.

@rbuckton
Copy link
Collaborator Author

rbuckton commented Mar 22, 2023

This is a fairly early draft, but I'd like to get some feedback on the cover grammar. I'll continue to add some of the missing semantics rules needed to apply the supplemental syntax in later commits.

@rbuckton
Copy link
Collaborator Author

I still need to review Contains and the early errors for delete to determine if there is additional work to do to support the cover grammar. In the case of Contains, we do not currently explicitly handle PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList, though we do handle ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList, so it is unclear whether something similar is needed.

@rbuckton rbuckton marked this pull request as ready for review March 22, 2023 17:25
@rbuckton
Copy link
Collaborator Author

Here are some potential test cases for this grammar:

await using

is parsed as an ExpressionStatement containing an AwaitExpression (covered by CoverAwaitExpressionAndAwaitUsingDeclarationHead).

await using
x = y

is parsed as an ExpressionStatement containing an AwaitExpression (covered by CoverAwaitExpressionAndAwaitUsingDeclarationHead), followed by an ExpressionStatement containing an AssignmentExpression.

await using x

is a syntax error. CoverAwaitExpressionAndAwaitUsingDeclarationHead is parsed for await using, but an IdentifierName cannot follow a UnaryExpression. This is then parsed as an AwaitUsingDeclaration, but an early error raises a syntax error due to the missing initializer.

await
using x

is a syntax error. CoverAwaitExpressionAndAwaitUsingDeclarationHead is parsed for await using, but an IdentifierName cannot follow a UnaryExpression. When attempting to parse as an AwaitUsingDeclaration, this fails to meet the supplemental syntax for AwaitUsingDeclarationHead.

await
using
x

is parsed as an ExpressionStatement containing an AwaitExpression (covered by CoverAwaitExpressionAndAwaitUsingDeclarationHead), followed by an ExpressionStatement containing an IdentifierReference.

@rbuckton
Copy link
Collaborator Author

@waldemarhorwat: I'd appreciate if you're able to review sometime this week.

spec.emu Outdated Show resolved Hide resolved
spec.emu Outdated Show resolved Hide resolved
spec.emu Outdated Show resolved Hide resolved
@@ -2962,6 +3356,37 @@ contributors: Ron Buckton, Ecma International
<emu-clause id="sec-async-function-definitions">
<h1>Async Function Definitions</h1>

<h2>Syntax</h2>

Choose a reason for hiding this comment

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

Why is a second definition of AsyncFunctionDeclaration pasted in the middle of the runtime semantics section? There already is a definition of AsyncFunctionDeclaration in the spec and I don't see the existing one being removed in this pull request.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure what you mean by this. There are no <ins> or <del> tags in the grammar below, so no changes were made. I included the grammar here for reference as AwaitExpression is referenced multiple times in the static semantics and runtime semantics.

@rbuckton rbuckton merged commit b010d25 into main Apr 11, 2023
@rbuckton rbuckton deleted the await-using branch April 11, 2023 01:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

using await/await using/async using
2 participants