Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
10 changes: 10 additions & 0 deletions tests/baselines/reference/usingDeclarationsInForOf.4.errors.txt
Original file line number Diff line number Diff line change
@@ -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 changes: 15 additions & 0 deletions tests/baselines/reference/usingDeclarationsInForOf.4.js
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;