Skip to content

Commit

Permalink
Remove using await restriction in explicitResourceManagement (#15602)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed May 2, 2023
1 parent 213de75 commit 2942629
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 14 deletions.
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

0 comments on commit 2942629

Please sign in to comment.