Skip to content

Commit f579f33

Browse files
authored
Revert "Don't treat a colon in a conditional expression branch as part of an arrow function" (#48940)
1 parent c8ec855 commit f579f33

33 files changed

+199
-124
lines changed

src/compiler/parser.ts

Lines changed: 32 additions & 50 deletions
Large diffs are not rendered by default.
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(1,1): error TS2304: Cannot find name 'a'.
2-
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(1,6): error TS2304: Cannot find name 'b'.
3-
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(1,17): error TS2304: Cannot find name 'd'.
4-
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(1,20): error TS1005: ';' expected.
2+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(1,11): error TS2304: Cannot find name 'c'.
3+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(1,22): error TS2304: Cannot find name 'e'.
54
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(1,27): error TS2304: Cannot find name 'f'.
5+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(2,1): error TS1005: ':' expected.
66

77

88
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts (5 errors) ====
99
a ? (b) : c => (d) : e => f
1010
~
1111
!!! error TS2304: Cannot find name 'a'.
12-
~
13-
!!! error TS2304: Cannot find name 'b'.
14-
~
15-
!!! error TS2304: Cannot find name 'd'.
16-
~
17-
!!! error TS1005: ';' expected.
12+
~
13+
!!! error TS2304: Cannot find name 'c'.
14+
~
15+
!!! error TS2304: Cannot find name 'e'.
1816
~
1917
!!! error TS2304: Cannot find name 'f'.
20-
18+
19+
20+
!!! error TS1005: ':' expected.

tests/baselines/reference/parserArrowFunctionExpression10.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ a ? (b) : c => (d) : e => f
33

44

55
//// [parserArrowFunctionExpression10.js]
6-
a ? (b) : function (c) { return (d); };
7-
(function (e) { return f; });
6+
a ? function (b) { return function (d) { return f; }; }
7+
:
8+
;
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts ===
22
a ? (b) : c => (d) : e => f
3-
>c : Symbol(c, Decl(parserArrowFunctionExpression10.ts, 0, 9))
4-
>e : Symbol(e, Decl(parserArrowFunctionExpression10.ts, 0, 20))
3+
>b : Symbol(b, Decl(parserArrowFunctionExpression10.ts, 0, 5))
4+
>c : Symbol(c)
5+
>d : Symbol(d, Decl(parserArrowFunctionExpression10.ts, 0, 16))
6+
>e : Symbol(e)
57

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts ===
22
a ? (b) : c => (d) : e => f
3-
>a ? (b) : c => (d) : any
3+
>a ? (b) : c => (d) : e => f : any
44
>a : any
5-
>(b) : any
5+
>(b) : c => (d) : e => f : (b: any) => c
66
>b : any
7-
>c => (d) : (c: any) => any
8-
>c : any
9-
>(d) : any
7+
>(d) : e => f : (d: any) => e
108
>d : any
11-
>e => f : (e: any) => any
12-
>e : any
139
>f : any
1410

11+
> : any
12+
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(1,1): error TS2304: Cannot find name 'a'.
22
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(1,5): error TS2304: Cannot find name 'b'.
33
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(1,9): error TS2304: Cannot find name 'c'.
4-
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(1,14): error TS2304: Cannot find name 'd'.
4+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(1,19): error TS2304: Cannot find name 'e'.
55
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(1,24): error TS2304: Cannot find name 'f'.
6+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(2,1): error TS1005: ':' expected.
67

78

8-
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts (5 errors) ====
9+
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts (6 errors) ====
910
a ? b ? c : (d) : e => f
1011
~
1112
!!! error TS2304: Cannot find name 'a'.
1213
~
1314
!!! error TS2304: Cannot find name 'b'.
1415
~
1516
!!! error TS2304: Cannot find name 'c'.
16-
~
17-
!!! error TS2304: Cannot find name 'd'.
17+
~
18+
!!! error TS2304: Cannot find name 'e'.
1819
~
1920
!!! error TS2304: Cannot find name 'f'.
20-
21+
22+
23+
!!! error TS1005: ':' expected.

tests/baselines/reference/parserArrowFunctionExpression11.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ a ? b ? c : (d) : e => f
33

44

55
//// [parserArrowFunctionExpression11.js]
6-
a ? b ? c : (d) : function (e) { return f; };
6+
a ? b ? c : function (d) { return f; }
7+
:
8+
;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts ===
22
a ? b ? c : (d) : e => f
3-
>e : Symbol(e, Decl(parserArrowFunctionExpression11.ts, 0, 17))
3+
>d : Symbol(d, Decl(parserArrowFunctionExpression11.ts, 0, 13))
4+
>e : Symbol(e)
45

tests/baselines/reference/parserArrowFunctionExpression11.types

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
a ? b ? c : (d) : e => f
33
>a ? b ? c : (d) : e => f : any
44
>a : any
5-
>b ? c : (d) : any
5+
>b ? c : (d) : e => f : any
66
>b : any
77
>c : any
8-
>(d) : any
8+
>(d) : e => f : (d: any) => e
99
>d : any
10-
>e => f : (e: any) => any
11-
>e : any
1210
>f : any
1311

12+
> : any
13+
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts(1,1): error TS2304: Cannot find name 'a'.
2-
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts(1,13): error TS2304: Cannot find name 'c'.
2+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts(1,17): error TS2304: Cannot find name 'd'.
33
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts(1,22): error TS2304: Cannot find name 'e'.
4+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts(2,1): error TS1005: ':' expected.
45

56

6-
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts (3 errors) ====
7+
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts (4 errors) ====
78
a ? (b) => (c): d => e
89
~
910
!!! error TS2304: Cannot find name 'a'.
10-
~
11-
!!! error TS2304: Cannot find name 'c'.
11+
~
12+
!!! error TS2304: Cannot find name 'd'.
1213
~
1314
!!! error TS2304: Cannot find name 'e'.
14-
15+
16+
17+
!!! error TS1005: ':' expected.

0 commit comments

Comments
 (0)