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

Lines changed: 61 additions & 34 deletions
Large diffs are not rendered by default.
Lines changed: 35 additions & 0 deletions
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+
Lines changed: 13 additions & 0 deletions
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; };
Lines changed: 12 additions & 0 deletions
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+
Lines changed: 24 additions & 0 deletions
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+
Lines changed: 35 additions & 0 deletions
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+
Lines changed: 13 additions & 0 deletions
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;
Lines changed: 12 additions & 0 deletions
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+
Lines changed: 24 additions & 0 deletions
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

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)