mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-11 09:24:19 -06:00
fix(61747): for (using of = is incorrectly parsed (#61764)
This commit is contained in:
parent
2b88aebaaa
commit
a591ca3fdc
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
15
tests/baselines/reference/usingDeclarationsInForOf.4.js
Normal file
15
tests/baselines/reference/usingDeclarationsInForOf.4.js
Normal 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;
|
||||
@ -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;
|
||||
Loading…
x
Reference in New Issue
Block a user