Skip to content

Commit b45f21e

Browse files
committed
Fix await using double lookahead edge case
1 parent 0ee7596 commit b45f21e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

acorn/src/statement.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ pp.isUsingKeyword = function(isAwaitUsing, isFor) {
8787
let usingEndPos = next + 5 /* using */, after
8888
if (this.input.slice(next, usingEndPos) !== "using" ||
8989
usingEndPos === this.input.length ||
90-
isIdentifierChar(after = this.input.charCodeAt(usingEndPos)) ||
91-
(after > 0xd7ff && after < 0xdc00)
90+
isIdentifierChar(after = this.fullCharCodeAt(usingEndPos)) ||
91+
after === 92 /* '\' */
9292
) return false
9393

9494
skipWhiteSpace.lastIndex = usingEndPos

test/tests-using.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,9 @@ testFail("for (await using a of x) {}", "Await using cannot appear outside of as
11841184
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"});
11851185
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"});
11861186

1187+
// await using double lookahead should detect using keyword correctly
1188+
testFail("async () => { await using\\u0061 b = c }", "Unexpected token (1:32)", {ecmaVersion: 17, sourceType: "module"});
1189+
11871190
// =============================================================================
11881191
// EDGE CASES - Unusual but valid scenarios and boundary conditions
11891192
// =============================================================================

0 commit comments

Comments
 (0)