forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed false positive syntax errors with in inside for (microsoft#54801)
Co-authored-by: Evan Wallace <[email protected]>
- Loading branch information
Showing
15 changed files
with
262 additions
and
2 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
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/parserForInStatement8.errors.txt
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,20 @@ | ||
parserForInStatement8.ts(3,10): error TS2461: Type 'string' is not an array type. | ||
parserForInStatement8.ts(3,10): error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. | ||
parserForInStatement8.ts(4,10): error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. | ||
parserForInStatement8.ts(4,11): error TS2339: Property 'x' does not exist on type 'String'. | ||
|
||
|
||
==== parserForInStatement8.ts (4 errors) ==== | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
|
||
for (let [x = 'a' in {}] in { '': 0 }) console.log(x) | ||
~~~~~~~~~~~~~~~ | ||
!!! error TS2461: Type 'string' is not an array type. | ||
~~~~~~~~~~~~~~~ | ||
!!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. | ||
for (let {x = 'a' in {}} in { '': 0 }) console.log(x) | ||
~~~~~~~~~~~~~~~ | ||
!!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern. | ||
~ | ||
!!! error TS2339: Property 'x' does not exist on type 'String'. | ||
|
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,15 @@ | ||
//// [tests/cases/conformance/parser/ecmascript5/Statements/parserForInStatement8.ts] //// | ||
|
||
//// [parserForInStatement8.ts] | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
|
||
for (let [x = 'a' in {}] in { '': 0 }) console.log(x) | ||
for (let {x = 'a' in {}} in { '': 0 }) console.log(x) | ||
|
||
|
||
//// [parserForInStatement8.js] | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
for (var _a = (void 0)[0], x = _a === void 0 ? 'a' in {} : _a in { '': 0 }) | ||
console.log(x); | ||
for (var _b = (void 0).x, x = _b === void 0 ? 'a' in {} : _b in { '': 0 }) | ||
console.log(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,21 @@ | ||
//// [tests/cases/conformance/parser/ecmascript5/Statements/parserForInStatement8.ts] //// | ||
|
||
=== parserForInStatement8.ts === | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
|
||
for (let [x = 'a' in {}] in { '': 0 }) console.log(x) | ||
>x : Symbol(x, Decl(parserForInStatement8.ts, 2, 10)) | ||
>'' : Symbol('', Decl(parserForInStatement8.ts, 2, 29)) | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>x : Symbol(x, Decl(parserForInStatement8.ts, 2, 10)) | ||
|
||
for (let {x = 'a' in {}} in { '': 0 }) console.log(x) | ||
>x : Symbol(x, Decl(parserForInStatement8.ts, 3, 10)) | ||
>'' : Symbol('', Decl(parserForInStatement8.ts, 3, 29)) | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>x : Symbol(x, Decl(parserForInStatement8.ts, 3, 10)) | ||
|
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,33 @@ | ||
//// [tests/cases/conformance/parser/ecmascript5/Statements/parserForInStatement8.ts] //// | ||
|
||
=== parserForInStatement8.ts === | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
|
||
for (let [x = 'a' in {}] in { '': 0 }) console.log(x) | ||
>x : any | ||
>'a' in {} : boolean | ||
>'a' : "a" | ||
>{} : {} | ||
>{ '': 0 } : { '': number; } | ||
>'' : number | ||
>0 : 0 | ||
>console.log(x) : void | ||
>console.log : (...data: any[]) => void | ||
>console : Console | ||
>log : (...data: any[]) => void | ||
>x : any | ||
|
||
for (let {x = 'a' in {}} in { '': 0 }) console.log(x) | ||
>x : any | ||
>'a' in {} : boolean | ||
>'a' : "a" | ||
>{} : {} | ||
>{ '': 0 } : { '': number; } | ||
>'' : number | ||
>0 : 0 | ||
>console.log(x) : void | ||
>console.log : (...data: any[]) => void | ||
>console : Console | ||
>log : (...data: any[]) => void | ||
>x : any | ||
|
11 changes: 11 additions & 0 deletions
11
tests/baselines/reference/parserForOfStatement25.errors.txt
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 @@ | ||
parserForOfStatement25.ts(4,11): error TS2339: Property 'x' does not exist on type '{}'. | ||
|
||
|
||
==== parserForOfStatement25.ts (1 errors) ==== | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
|
||
for (let [x = 'a' in {}] of [[]]) console.log(x) | ||
for (let {x = 'a' in {}} of [{}]) console.log(x) | ||
~ | ||
!!! error TS2339: Property 'x' does not exist on type '{}'. | ||
|
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,15 @@ | ||
//// [tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement25.ts] //// | ||
|
||
//// [parserForOfStatement25.ts] | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
|
||
for (let [x = 'a' in {}] of [[]]) console.log(x) | ||
for (let {x = 'a' in {}} of [{}]) console.log(x) | ||
|
||
|
||
//// [parserForOfStatement25.js] | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
for (let [x = 'a' in {}] of [[]]) | ||
console.log(x); | ||
for (let { x = 'a' in {} } of [{}]) | ||
console.log(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,19 @@ | ||
//// [tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement25.ts] //// | ||
|
||
=== parserForOfStatement25.ts === | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
|
||
for (let [x = 'a' in {}] of [[]]) console.log(x) | ||
>x : Symbol(x, Decl(parserForOfStatement25.ts, 2, 10)) | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>x : Symbol(x, Decl(parserForOfStatement25.ts, 2, 10)) | ||
|
||
for (let {x = 'a' in {}} of [{}]) console.log(x) | ||
>x : Symbol(x, Decl(parserForOfStatement25.ts, 3, 10)) | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>x : Symbol(x, Decl(parserForOfStatement25.ts, 3, 10)) | ||
|
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,31 @@ | ||
//// [tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement25.ts] //// | ||
|
||
=== parserForOfStatement25.ts === | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
|
||
for (let [x = 'a' in {}] of [[]]) console.log(x) | ||
>x : boolean | ||
>'a' in {} : boolean | ||
>'a' : "a" | ||
>{} : {} | ||
>[[]] : undefined[][] | ||
>[] : undefined[] | ||
>console.log(x) : void | ||
>console.log : (...data: any[]) => void | ||
>console : Console | ||
>log : (...data: any[]) => void | ||
>x : boolean | ||
|
||
for (let {x = 'a' in {}} of [{}]) console.log(x) | ||
>x : any | ||
>'a' in {} : boolean | ||
>'a' : "a" | ||
>{} : {} | ||
>[{}] : {}[] | ||
>{} : {} | ||
>console.log(x) : void | ||
>console.log : (...data: any[]) => void | ||
>console : Console | ||
>log : (...data: any[]) => void | ||
>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,15 @@ | ||
//// [tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement9.ts] //// | ||
|
||
//// [parserForStatement9.ts] | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
|
||
for (let [x = 'a' in {}] = []; !x; x = !x) console.log(x) | ||
for (let {x = 'a' in {}} = {}; !x; x = !x) console.log(x) | ||
|
||
|
||
//// [parserForStatement9.js] | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
for (var _a = [][0], x = _a === void 0 ? 'a' in {} : _a; !x; x = !x) | ||
console.log(x); | ||
for (var _b = {}.x, x = _b === void 0 ? 'a' in {} : _b; !x; x = !x) | ||
console.log(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,25 @@ | ||
//// [tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement9.ts] //// | ||
|
||
=== parserForStatement9.ts === | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
|
||
for (let [x = 'a' in {}] = []; !x; x = !x) console.log(x) | ||
>x : Symbol(x, Decl(parserForStatement9.ts, 2, 10)) | ||
>x : Symbol(x, Decl(parserForStatement9.ts, 2, 10)) | ||
>x : Symbol(x, Decl(parserForStatement9.ts, 2, 10)) | ||
>x : Symbol(x, Decl(parserForStatement9.ts, 2, 10)) | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>x : Symbol(x, Decl(parserForStatement9.ts, 2, 10)) | ||
|
||
for (let {x = 'a' in {}} = {}; !x; x = !x) console.log(x) | ||
>x : Symbol(x, Decl(parserForStatement9.ts, 3, 10)) | ||
>x : Symbol(x, Decl(parserForStatement9.ts, 3, 10)) | ||
>x : Symbol(x, Decl(parserForStatement9.ts, 3, 10)) | ||
>x : Symbol(x, Decl(parserForStatement9.ts, 3, 10)) | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>x : Symbol(x, Decl(parserForStatement9.ts, 3, 10)) | ||
|
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,41 @@ | ||
//// [tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement9.ts] //// | ||
|
||
=== parserForStatement9.ts === | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
|
||
for (let [x = 'a' in {}] = []; !x; x = !x) console.log(x) | ||
>x : boolean | ||
>'a' in {} : boolean | ||
>'a' : "a" | ||
>{} : {} | ||
>[] : [] | ||
>!x : boolean | ||
>x : boolean | ||
>x = !x : boolean | ||
>x : boolean | ||
>!x : boolean | ||
>x : boolean | ||
>console.log(x) : void | ||
>console.log : (...data: any[]) => void | ||
>console : Console | ||
>log : (...data: any[]) => void | ||
>x : boolean | ||
|
||
for (let {x = 'a' in {}} = {}; !x; x = !x) console.log(x) | ||
>x : boolean | ||
>'a' in {} : boolean | ||
>'a' : "a" | ||
>{} : {} | ||
>{} : { x?: boolean; } | ||
>!x : boolean | ||
>x : boolean | ||
>x = !x : boolean | ||
>x : boolean | ||
>!x : boolean | ||
>x : boolean | ||
>console.log(x) : void | ||
>console.log : (...data: any[]) => void | ||
>console : Console | ||
>log : (...data: any[]) => void | ||
>x : boolean | ||
|
4 changes: 4 additions & 0 deletions
4
tests/cases/conformance/parser/ecmascript5/Statements/parserForInStatement8.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 @@ | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
|
||
for (let [x = 'a' in {}] in { '': 0 }) console.log(x) | ||
for (let {x = 'a' in {}} in { '': 0 }) console.log(x) |
4 changes: 4 additions & 0 deletions
4
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement9.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 @@ | ||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
|
||
for (let [x = 'a' in {}] = []; !x; x = !x) console.log(x) | ||
for (let {x = 'a' in {}} = {}; !x; x = !x) console.log(x) |
6 changes: 6 additions & 0 deletions
6
tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement25.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 | ||
|
||
// repro from https://github.com/microsoft/TypeScript/issues/54769 | ||
|
||
for (let [x = 'a' in {}] of [[]]) console.log(x) | ||
for (let {x = 'a' in {}} of [{}]) console.log(x) |