Skip to content

Commit d7e58c8

Browse files
authored
Fix arrow expressions in conditional expressions, take N+1 (microsoft#49531)
1 parent 6004b35 commit d7e58c8

File tree

130 files changed

+1580
-431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+1580
-431
lines changed

src/compiler/parser.ts

+61-34
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,1): error TS2304: Cannot find name 'a'.
2+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,11): error TS2304: Cannot find name 'c'.
3+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files.
4+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,17): error TS2304: Cannot find name 'd'.
5+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,27): error TS2304: Cannot find name 'f'.
6+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,1): error TS2304: Cannot find name 'a'.
7+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,11): error TS2304: Cannot find name 'c'.
8+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,17): error TS2304: Cannot find name 'd'.
9+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,27): error TS2304: Cannot find name 'f'.
10+
11+
12+
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js (5 errors) ====
13+
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon
14+
~
15+
!!! error TS2304: Cannot find name 'a'.
16+
~
17+
!!! error TS2304: Cannot find name 'c'.
18+
~
19+
!!! error TS8010: Type annotations can only be used in TypeScript files.
20+
~
21+
!!! error TS2304: Cannot find name 'd'.
22+
~
23+
!!! error TS2304: Cannot find name 'f'.
24+
25+
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts (4 errors) ====
26+
a ? (b) : c => (d) : e => f
27+
~
28+
!!! error TS2304: Cannot find name 'a'.
29+
~
30+
!!! error TS2304: Cannot find name 'c'.
31+
~
32+
!!! error TS2304: Cannot find name 'd'.
33+
~
34+
!!! error TS2304: Cannot find name 'f'.
35+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts] ////
2+
3+
//// [fileJs.js]
4+
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon
5+
6+
//// [fileTs.ts]
7+
a ? (b) : c => (d) : e => f
8+
9+
10+
//// [fileJs.js]
11+
a ? function (b) { return (d); } : function (e) { return f; }; // Not legal JS; "Unexpected token ':'" at last colon
12+
//// [fileTs.js]
13+
a ? function (b) { return (d); } : function (e) { return f; };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js ===
2+
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon
3+
>b : Symbol(b, Decl(fileJs.js, 0, 5))
4+
>c : Symbol(c)
5+
>e : Symbol(e, Decl(fileJs.js, 0, 20))
6+
7+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts ===
8+
a ? (b) : c => (d) : e => f
9+
>b : Symbol(b, Decl(fileTs.ts, 0, 5))
10+
>c : Symbol(c)
11+
>e : Symbol(e, Decl(fileTs.ts, 0, 20))
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js ===
2+
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon
3+
>a ? (b) : c => (d) : e => f : (b: any) => c
4+
>a : any
5+
>(b) : c => (d) : (b: any) => c
6+
>b : any
7+
>(d) : any
8+
>d : any
9+
>e => f : (e: any) => any
10+
>e : any
11+
>f : any
12+
13+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts ===
14+
a ? (b) : c => (d) : e => f
15+
>a ? (b) : c => (d) : e => f : (b: any) => c
16+
>a : any
17+
>(b) : c => (d) : (b: any) => c
18+
>b : any
19+
>(d) : any
20+
>d : any
21+
>e => f : (e: any) => any
22+
>e : any
23+
>f : any
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,1): error TS2304: Cannot find name 'a'.
2+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,11): error TS2304: Cannot find name 'c'.
3+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files.
4+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,17): error TS2304: Cannot find name 'd'.
5+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,27): error TS2304: Cannot find name 'f'.
6+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,1): error TS2304: Cannot find name 'a'.
7+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,11): error TS2304: Cannot find name 'c'.
8+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,17): error TS2304: Cannot find name 'd'.
9+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,27): error TS2304: Cannot find name 'f'.
10+
11+
12+
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js (5 errors) ====
13+
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon
14+
~
15+
!!! error TS2304: Cannot find name 'a'.
16+
~
17+
!!! error TS2304: Cannot find name 'c'.
18+
~
19+
!!! error TS8010: Type annotations can only be used in TypeScript files.
20+
~
21+
!!! error TS2304: Cannot find name 'd'.
22+
~
23+
!!! error TS2304: Cannot find name 'f'.
24+
25+
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts (4 errors) ====
26+
a ? (b) : c => (d) : e => f
27+
~
28+
!!! error TS2304: Cannot find name 'a'.
29+
~
30+
!!! error TS2304: Cannot find name 'c'.
31+
~
32+
!!! error TS2304: Cannot find name 'd'.
33+
~
34+
!!! error TS2304: Cannot find name 'f'.
35+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts] ////
2+
3+
//// [fileJs.js]
4+
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon
5+
6+
//// [fileTs.ts]
7+
a ? (b) : c => (d) : e => f
8+
9+
10+
//// [fileJs.js]
11+
a ? (b) => (d) : e => f; // Not legal JS; "Unexpected token ':'" at last colon
12+
//// [fileTs.js]
13+
a ? (b) => (d) : e => f;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js ===
2+
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon
3+
>b : Symbol(b, Decl(fileJs.js, 0, 5))
4+
>c : Symbol(c)
5+
>e : Symbol(e, Decl(fileJs.js, 0, 20))
6+
7+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts ===
8+
a ? (b) : c => (d) : e => f
9+
>b : Symbol(b, Decl(fileTs.ts, 0, 5))
10+
>c : Symbol(c)
11+
>e : Symbol(e, Decl(fileTs.ts, 0, 20))
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js ===
2+
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon
3+
>a ? (b) : c => (d) : e => f : (b: any) => c
4+
>a : any
5+
>(b) : c => (d) : (b: any) => c
6+
>b : any
7+
>(d) : any
8+
>d : any
9+
>e => f : (e: any) => any
10+
>e : any
11+
>f : any
12+
13+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts ===
14+
a ? (b) : c => (d) : e => f
15+
>a ? (b) : c => (d) : e => f : (b: any) => c
16+
>a : any
17+
>(b) : c => (d) : (b: any) => c
18+
>b : any
19+
>(d) : any
20+
>d : any
21+
>e => f : (e: any) => any
22+
>e : any
23+
>f : any
24+

tests/baselines/reference/parserArrowFunctionExpression10.errors.txt

-20
This file was deleted.

tests/baselines/reference/parserArrowFunctionExpression10.js

-8
This file was deleted.

tests/baselines/reference/parserArrowFunctionExpression10.symbols

-7
This file was deleted.

tests/baselines/reference/parserArrowFunctionExpression10.types

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,1): error TS2304: Cannot find name 'a'.
2+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,5): error TS2304: Cannot find name 'b'.
3+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,9): error TS2304: Cannot find name 'c'.
4+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,14): error TS2304: Cannot find name 'd'.
5+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,24): error TS2304: Cannot find name 'f'.
6+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,1): error TS2304: Cannot find name 'a'.
7+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,5): error TS2304: Cannot find name 'b'.
8+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,9): error TS2304: Cannot find name 'c'.
9+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,14): error TS2304: Cannot find name 'd'.
10+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,24): error TS2304: Cannot find name 'f'.
11+
12+
13+
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js (5 errors) ====
14+
a ? b ? c : (d) : e => f // Legal JS
15+
~
16+
!!! error TS2304: Cannot find name 'a'.
17+
~
18+
!!! error TS2304: Cannot find name 'b'.
19+
~
20+
!!! error TS2304: Cannot find name 'c'.
21+
~
22+
!!! error TS2304: Cannot find name 'd'.
23+
~
24+
!!! error TS2304: Cannot find name 'f'.
25+
26+
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts (5 errors) ====
27+
a ? b ? c : (d) : e => f
28+
~
29+
!!! error TS2304: Cannot find name 'a'.
30+
~
31+
!!! error TS2304: Cannot find name 'b'.
32+
~
33+
!!! error TS2304: Cannot find name 'c'.
34+
~
35+
!!! error TS2304: Cannot find name 'd'.
36+
~
37+
!!! error TS2304: Cannot find name 'f'.
38+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts] ////
2+
3+
//// [fileJs.js]
4+
a ? b ? c : (d) : e => f // Legal JS
5+
6+
//// [fileTs.ts]
7+
a ? b ? c : (d) : e => f
8+
9+
10+
//// [fileJs.js]
11+
a ? b ? c : (d) : function (e) { return f; }; // Legal JS
12+
//// [fileTs.js]
13+
a ? b ? c : (d) : function (e) { return f; };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js ===
2+
a ? b ? c : (d) : e => f // Legal JS
3+
>e : Symbol(e, Decl(fileJs.js, 0, 17))
4+
5+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts ===
6+
a ? b ? c : (d) : e => f
7+
>e : Symbol(e, Decl(fileTs.ts, 0, 17))
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js ===
2+
a ? b ? c : (d) : e => f // Legal JS
3+
>a ? b ? c : (d) : e => f : any
4+
>a : any
5+
>b ? c : (d) : any
6+
>b : any
7+
>c : any
8+
>(d) : any
9+
>d : any
10+
>e => f : (e: any) => any
11+
>e : any
12+
>f : any
13+
14+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts ===
15+
a ? b ? c : (d) : e => f
16+
>a ? b ? c : (d) : e => f : any
17+
>a : any
18+
>b ? c : (d) : any
19+
>b : any
20+
>c : any
21+
>(d) : any
22+
>d : any
23+
>e => f : (e: any) => any
24+
>e : any
25+
>f : any
26+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,1): error TS2304: Cannot find name 'a'.
2+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,5): error TS2304: Cannot find name 'b'.
3+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,9): error TS2304: Cannot find name 'c'.
4+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,14): error TS2304: Cannot find name 'd'.
5+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,24): error TS2304: Cannot find name 'f'.
6+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,1): error TS2304: Cannot find name 'a'.
7+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,5): error TS2304: Cannot find name 'b'.
8+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,9): error TS2304: Cannot find name 'c'.
9+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,14): error TS2304: Cannot find name 'd'.
10+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,24): error TS2304: Cannot find name 'f'.
11+
12+
13+
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js (5 errors) ====
14+
a ? b ? c : (d) : e => f // Legal JS
15+
~
16+
!!! error TS2304: Cannot find name 'a'.
17+
~
18+
!!! error TS2304: Cannot find name 'b'.
19+
~
20+
!!! error TS2304: Cannot find name 'c'.
21+
~
22+
!!! error TS2304: Cannot find name 'd'.
23+
~
24+
!!! error TS2304: Cannot find name 'f'.
25+
26+
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts (5 errors) ====
27+
a ? b ? c : (d) : e => f
28+
~
29+
!!! error TS2304: Cannot find name 'a'.
30+
~
31+
!!! error TS2304: Cannot find name 'b'.
32+
~
33+
!!! error TS2304: Cannot find name 'c'.
34+
~
35+
!!! error TS2304: Cannot find name 'd'.
36+
~
37+
!!! error TS2304: Cannot find name 'f'.
38+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts] ////
2+
3+
//// [fileJs.js]
4+
a ? b ? c : (d) : e => f // Legal JS
5+
6+
//// [fileTs.ts]
7+
a ? b ? c : (d) : e => f
8+
9+
10+
//// [fileJs.js]
11+
a ? b ? c : (d) : e => f; // Legal JS
12+
//// [fileTs.js]
13+
a ? b ? c : (d) : e => f;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js ===
2+
a ? b ? c : (d) : e => f // Legal JS
3+
>e : Symbol(e, Decl(fileJs.js, 0, 17))
4+
5+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts ===
6+
a ? b ? c : (d) : e => f
7+
>e : Symbol(e, Decl(fileTs.ts, 0, 17))
8+

0 commit comments

Comments
 (0)