You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/tests-using.js
+7-2Lines changed: 7 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1102,14 +1102,14 @@ testFail("let await using x = resource;", "Cannot use keyword 'await' outside an
1102
1102
// let using is not allowed
1103
1103
testFail("let using x = resource;","Unexpected token (1:10)",{ecmaVersion: 17,sourceType: "module"});
1104
1104
// top level using is not allowed
1105
-
testFail("using x = resource;","Using declaration cannot appear in the top level when source type is `script` (1:0)",{ecmaVersion: 17,sourceType: "script"});
1105
+
testFail("using x = resource;","Using declaration cannot appear in the top level when source type is `script` or in the bare case statement (1:0)",{ecmaVersion: 17,sourceType: "script"});
1106
1106
1107
1107
// BoundNames contains "let"
1108
1108
testFail("async function test() { await using let = resource; }","The keyword 'let' is reserved (1:36)",{ecmaVersion: 17,sourceType: "module"});
1109
1109
// BoundNames contains duplicate entries
1110
1110
testFail("async function test() { await using x = resource1, x = resource2; }","Identifier 'x' has already been declared (1:51)",{ecmaVersion: 17,sourceType: "module"});
1111
1111
// top level await using is not allowed
1112
-
testFail("await using x = resource;","Using declaration cannot appear in the top level when source type is `script` (1:0)",{ecmaVersion: 17,sourceType: "script"});
1112
+
testFail("await using x = resource;","Using declaration cannot appear in the top level when source type is `script` or in the bare case statement (1:0)",{ecmaVersion: 17,sourceType: "script"});
1113
1113
1114
1114
// Basic missing initializer
1115
1115
testFail("{ using x; }","Missing initializer in using declaration (1:9)",{ecmaVersion: 17,sourceType: "module"});
testFail("{await using a = x}","Await using cannot appear outside of async function (1:1)",{ecmaVersion: 17,sourceType: "script"});
1181
+
testFail("for (await using a of x) {}","Await using cannot appear outside of async function (1:11)",{ecmaVersion: 17,sourceType: "script"});
1182
+
1183
+
// Using in a bare case statement (should not be allowed)
1184
+
testFail("switch (x) { case 1: using y = resource; }","Using declaration cannot appear in the top level when source type is `script` or in the bare case statement (1:21)",{ecmaVersion: 17,sourceType: "module"});
1185
+
testFail("switch (x) { case 1: break; default: using y = resource; }","Using declaration cannot appear in the top level when source type is `script` or in the bare case statement (1:37)",{ecmaVersion: 17,sourceType: "module"});
0 commit comments