Skip to content

Commit d2b28bc

Browse files
committed
Disallow 'using' in 'switch'
1 parent 5b2247a commit d2b28bc

4 files changed

Lines changed: 48 additions & 122 deletions

test/language/statements/await-using/initializer-Symbol.asyncDispose-called-at-end-of-switchstatement.js

Lines changed: 0 additions & 61 deletions
This file was deleted.

test/language/statements/await-using/initializer-Symbol.dispose-called-at-end-of-switchstatement.js

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (C) 2025 Ron Buckton. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-let-const-using-and-await-using-declarations-static-semantics-early-errors
6+
description: Disallowed in switch statement
7+
info: |
8+
- It is a Syntax Error if the goal symbol is |Script| and |AwaitUsingDeclaration| is not contained, either directly or indirectly, within a |Block|, |ForStatement|, |ForInOfStatement|, |FunctionBody|, |GeneratorBody|, |AsyncGeneratorBody|, |AsyncFunctionBody|, or |ClassStaticBlockBody|.
9+
- It is a Syntax Error if |AwaitUsingDeclaration| is contained directly within the |StatementList| of either a |CaseClause| or |DefaultClause|.
10+
11+
negative:
12+
phase: parse
13+
type: SyntaxError
14+
15+
features: [explicit-resource-management]
16+
---*/
17+
18+
async function f() {
19+
switch (0) {
20+
case 0:
21+
await using _ = null;
22+
break;
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (C) 2025 Ron Buckton. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-let-const-using-and-await-using-declarations-static-semantics-early-errors
6+
description: Disallowed in switch statement
7+
info: |
8+
- It is a Syntax Error if the goal symbol is |Script| and |AwaitUsingDeclaration| is not contained, either directly or indirectly, within a |Block|, |ForStatement|, |ForInOfStatement|, |FunctionBody|, |GeneratorBody|, |AsyncGeneratorBody|, |AsyncFunctionBody|, or |ClassStaticBlockBody|.
9+
- It is a Syntax Error if |AwaitUsingDeclaration| is contained directly within the |StatementList| of either a |CaseClause| or |DefaultClause|.
10+
11+
negative:
12+
phase: parse
13+
type: SyntaxError
14+
15+
features: [explicit-resource-management]
16+
---*/
17+
18+
async function f() {
19+
switch (0) {
20+
default:
21+
await using _ = null;
22+
break;
23+
}
24+
}

0 commit comments

Comments
 (0)