Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove using await restriction in explicitResourceManagement #15602

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/babel-parser/src/parse-error/standard-errors.ts
Expand Up @@ -33,8 +33,6 @@ export default {
"Can not use 'await' as identifier inside a static block.",
AwaitExpressionFormalParameter:
"'await' is not allowed in async function parameters.",
AwaitInUsingBinding:
"'await' is not allowed to be used as a name in 'using' declarations.",
AwaitNotInAsyncContext:
"'await' is only allowed within async functions and at the top levels of modules.",
AwaitNotInAsyncFunction: "'await' is only allowed within async functions.",
Expand Down
7 changes: 1 addition & 6 deletions packages/babel-parser/src/parser/statement.ts
Expand Up @@ -484,7 +484,7 @@ export default abstract class StatementParser extends ExpressionParser {
return this.parseTryStatement(node as Undone<N.TryStatement>);

case tt._using:
// using [no LineTerminator here][lookahead != `await`] BindingList[+Using]
// using [no LineTerminator here] BindingList[+Using]
if (
this.state.containsEsc ||
!this.hasInLineFollowingBindingIdentifier()
Expand Down Expand Up @@ -1536,11 +1536,6 @@ export default abstract class StatementParser extends ExpressionParser {
decl: Undone<N.VariableDeclarator>,
kind: "var" | "let" | "const" | "using",
): void {
// Unlike "let" which must be handled in checkLVal, it suffices to check
// await here because `using` must not precede binding patterns.
if (kind === "using" && !this.inModule && this.match(tt._await)) {
this.raise(Errors.AwaitInUsingBinding, { at: this.state.startLoc });
}
const id = this.parseBindingAtom();
this.checkLVal(id, {
in: { type: "VariableDeclarator" },
Expand Down
@@ -1,12 +1,6 @@
{
"type": "File",
"start":0,"end":113,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":12,"column":1,"index":113}},
"errors": [
"SyntaxError: 'await' is not allowed to be used as a name in 'using' declarations. (2:8)",
"SyntaxError: 'await' is not allowed to be used as a name in 'using' declarations. (5:8)",
"SyntaxError: 'await' is not allowed to be used as a name in 'using' declarations. (8:11)",
"SyntaxError: 'await' is not allowed to be used as a name in 'using' declarations. (11:13)"
],
"program": {
"type": "Program",
"start":0,"end":113,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":12,"column":1,"index":113}},
Expand Down