fix(61747): for (using of = is incorrectly parsed (#61764)

This commit is contained in:
Oleksandr T. 2025-06-06 02:37:40 +03:00 committed by GitHub
parent 2b88aebaaa
commit a591ca3fdc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 41 additions and 1 deletions

View File

@ -7328,9 +7328,16 @@ namespace Parser {
return nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine(/*disallowOf*/ true);
}
function nextTokenIsEqualsOrSemicolonOrColonToken() {
nextToken();
return token() === SyntaxKind.EqualsToken || token() === SyntaxKind.SemicolonToken || token() === SyntaxKind.ColonToken;
}
function nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine(disallowOf?: boolean) {
nextToken();
if (disallowOf && token() === SyntaxKind.OfKeyword) return false;
if (disallowOf && token() === SyntaxKind.OfKeyword) {
return lookAhead(nextTokenIsEqualsOrSemicolonOrColonToken);
}
return (isBindingIdentifier() || token() === SyntaxKind.OpenBraceToken) && !scanner.hasPrecedingLineBreak();
}

View File

@ -0,0 +1,10 @@
usingDeclarationsInForOf.4.ts(3,12): error TS1155: 'using' declarations must be initialized.
==== usingDeclarationsInForOf.4.ts (1 errors) ====
for (using of = null;;) break;
for (using of: null = null;;) break;
for (using of;;) break;
~~
!!! error TS1155: 'using' declarations must be initialized.

View File

@ -0,0 +1,15 @@
//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.4.ts] ////
//// [usingDeclarationsInForOf.4.ts]
for (using of = null;;) break;
for (using of: null = null;;) break;
for (using of;;) break;
//// [usingDeclarationsInForOf.4.js]
for (using of = null;;)
break;
for (using of = null;;)
break;
for (using of;;)
break;

View File

@ -0,0 +1,8 @@
// @target: esnext
// @module: esnext
// @lib: esnext
// @noTypesAndSymbols: true
for (using of = null;;) break;
for (using of: null = null;;) break;
for (using of;;) break;