-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(43879): forbid async in the left hand in a for-of statement (#43886)
- Loading branch information
1 parent
463c794
commit 7aacd6b
Showing
19 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//// [for-inStatementsAsyncIdentifier.ts] | ||
var async; | ||
for (async in { a: 1, b: 2 }) {} | ||
|
||
|
||
//// [for-inStatementsAsyncIdentifier.js] | ||
var async; | ||
for (async in { a: 1, b: 2 }) { } |
9 changes: 9 additions & 0 deletions
9
tests/baselines/reference/for-inStatementsAsyncIdentifier.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
=== tests/cases/conformance/statements/for-inStatements/for-inStatementsAsyncIdentifier.ts === | ||
var async; | ||
>async : Symbol(async, Decl(for-inStatementsAsyncIdentifier.ts, 0, 3)) | ||
|
||
for (async in { a: 1, b: 2 }) {} | ||
>async : Symbol(async, Decl(for-inStatementsAsyncIdentifier.ts, 0, 3)) | ||
>a : Symbol(a, Decl(for-inStatementsAsyncIdentifier.ts, 1, 15)) | ||
>b : Symbol(b, Decl(for-inStatementsAsyncIdentifier.ts, 1, 21)) | ||
|
12 changes: 12 additions & 0 deletions
12
tests/baselines/reference/for-inStatementsAsyncIdentifier.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
=== tests/cases/conformance/statements/for-inStatements/for-inStatementsAsyncIdentifier.ts === | ||
var async; | ||
>async : any | ||
|
||
for (async in { a: 1, b: 2 }) {} | ||
>async : any | ||
>{ a: 1, b: 2 } : { a: number; b: number; } | ||
>a : number | ||
>1 : 1 | ||
>b : number | ||
>2 : 2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement22.ts(2,6): error TS1106: The left-hand side of a 'for...of' statement may not be 'async'. | ||
|
||
|
||
==== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement22.ts (1 errors) ==== | ||
var async; | ||
for (async of [1, 2]) {} | ||
~~~~~ | ||
!!! error TS1106: The left-hand side of a 'for...of' statement may not be 'async'. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//// [parserForOfStatement22.ts] | ||
var async; | ||
for (async of [1, 2]) {} | ||
|
||
|
||
//// [parserForOfStatement22.js] | ||
var async; | ||
for (async of [1, 2]) { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement22.ts === | ||
var async; | ||
>async : Symbol(async, Decl(parserForOfStatement22.ts, 0, 3)) | ||
|
||
for (async of [1, 2]) {} | ||
>async : Symbol(async, Decl(parserForOfStatement22.ts, 0, 3)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement22.ts === | ||
var async; | ||
>async : any | ||
|
||
for (async of [1, 2]) {} | ||
>async : any | ||
>[1, 2] : number[] | ||
>1 : 1 | ||
>2 : 2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//// [parserForOfStatement23.ts] | ||
async function foo(x: any) { | ||
var async; | ||
for await (async of x) {} | ||
} | ||
|
||
|
||
//// [parserForOfStatement23.js] | ||
async function foo(x) { | ||
var async; | ||
for await (async of x) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement23.ts === | ||
async function foo(x: any) { | ||
>foo : Symbol(foo, Decl(parserForOfStatement23.ts, 0, 0)) | ||
>x : Symbol(x, Decl(parserForOfStatement23.ts, 0, 19)) | ||
|
||
var async; | ||
>async : Symbol(async, Decl(parserForOfStatement23.ts, 1, 7)) | ||
|
||
for await (async of x) {} | ||
>async : Symbol(async, Decl(parserForOfStatement23.ts, 1, 7)) | ||
>x : Symbol(x, Decl(parserForOfStatement23.ts, 0, 19)) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement23.ts === | ||
async function foo(x: any) { | ||
>foo : (x: any) => Promise<void> | ||
>x : any | ||
|
||
var async; | ||
>async : any | ||
|
||
for await (async of x) {} | ||
>async : any | ||
>x : any | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//// [parserForOfStatement24.ts] | ||
var async; | ||
for ((async) of [1, 2]); | ||
|
||
|
||
//// [parserForOfStatement24.js] | ||
var async; | ||
for ((async) of [1, 2]) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement24.ts === | ||
var async; | ||
>async : Symbol(async, Decl(parserForOfStatement24.ts, 0, 3)) | ||
|
||
for ((async) of [1, 2]); | ||
>async : Symbol(async, Decl(parserForOfStatement24.ts, 0, 3)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
=== tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement24.ts === | ||
var async; | ||
>async : any | ||
|
||
for ((async) of [1, 2]); | ||
>(async) : any | ||
>async : any | ||
>[1, 2] : number[] | ||
>1 : 1 | ||
>2 : 2 | ||
|
4 changes: 4 additions & 0 deletions
4
tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement22.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// @target: esnext | ||
|
||
var async; | ||
for (async of [1, 2]) {} |
6 changes: 6 additions & 0 deletions
6
tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement23.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// @target: esnext | ||
|
||
async function foo(x: any) { | ||
var async; | ||
for await (async of x) {} | ||
} |
4 changes: 4 additions & 0 deletions
4
tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement24.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// @target: esnext | ||
|
||
var async; | ||
for ((async) of [1, 2]); |
4 changes: 4 additions & 0 deletions
4
tests/cases/conformance/statements/for-inStatements/for-inStatementsAsyncIdentifier.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// @target: esnext | ||
|
||
var async; | ||
for (async in { a: 1, b: 2 }) {} |