Skip to content

Commit 2dede20

Browse files
authored
Don't treat a colon in a conditional expression branch as part of an arrow function (microsoft#47550)
1 parent dda6583 commit 2dede20

File tree

41 files changed

+363
-32
lines changed

Some content is hidden

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

41 files changed

+363
-32
lines changed

src/compiler/parser.ts

Lines changed: 50 additions & 32 deletions
Large diffs are not rendered by default.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
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.
5+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(1,27): error TS2304: Cannot find name 'f'.
6+
7+
8+
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts (5 errors) ====
9+
a ? (b) : c => (d) : e => f
10+
~
11+
!!! 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.
18+
~
19+
!!! error TS2304: Cannot find name 'f'.
20+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//// [parserArrowFunctionExpression10.ts]
2+
a ? (b) : c => (d) : e => f
3+
4+
5+
//// [parserArrowFunctionExpression10.js]
6+
a ? (b) : function (c) { return (d); };
7+
(function (e) { return f; });
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts ===
2+
a ? (b) : c => (d) : e => f
3+
>c : Symbol(c, Decl(parserArrowFunctionExpression10.ts, 0, 9))
4+
>e : Symbol(e, Decl(parserArrowFunctionExpression10.ts, 0, 20))
5+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts ===
2+
a ? (b) : c => (d) : e => f
3+
>a ? (b) : c => (d) : any
4+
>a : any
5+
>(b) : any
6+
>b : any
7+
>c => (d) : (c: any) => any
8+
>c : any
9+
>(d) : any
10+
>d : any
11+
>e => f : (e: any) => any
12+
>e : any
13+
>f : any
14+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(1,1): error TS2304: Cannot find name 'a'.
2+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(1,5): error TS2304: Cannot find name 'b'.
3+
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'.
5+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(1,24): error TS2304: Cannot find name 'f'.
6+
7+
8+
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts (5 errors) ====
9+
a ? b ? c : (d) : e => f
10+
~
11+
!!! error TS2304: Cannot find name 'a'.
12+
~
13+
!!! error TS2304: Cannot find name 'b'.
14+
~
15+
!!! error TS2304: Cannot find name 'c'.
16+
~
17+
!!! error TS2304: Cannot find name 'd'.
18+
~
19+
!!! error TS2304: Cannot find name 'f'.
20+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//// [parserArrowFunctionExpression11.ts]
2+
a ? b ? c : (d) : e => f
3+
4+
5+
//// [parserArrowFunctionExpression11.js]
6+
a ? b ? c : (d) : function (e) { return f; };
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts ===
2+
a ? b ? c : (d) : e => f
3+
>e : Symbol(e, Decl(parserArrowFunctionExpression11.ts, 0, 17))
4+
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/parserArrowFunctionExpression11.ts ===
2+
a ? b ? c : (d) : e => f
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+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
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'.
3+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts(1,22): error TS2304: Cannot find name 'e'.
4+
5+
6+
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts (3 errors) ====
7+
a ? (b) => (c): d => e
8+
~
9+
!!! error TS2304: Cannot find name 'a'.
10+
~
11+
!!! error TS2304: Cannot find name 'c'.
12+
~
13+
!!! error TS2304: Cannot find name 'e'.
14+

0 commit comments

Comments
 (0)