Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix arrow expressions in conditional expressions, take N+1 #49531

Merged
merged 6 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 61 additions & 34 deletions src/compiler/parser.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,1): error TS2304: Cannot find name 'a'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,11): error TS2304: Cannot find name 'c'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,17): error TS2304: Cannot find name 'd'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,27): error TS2304: Cannot find name 'f'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,1): error TS2304: Cannot find name 'a'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,11): error TS2304: Cannot find name 'c'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,17): error TS2304: Cannot find name 'd'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,27): error TS2304: Cannot find name 'f'.


==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js (5 errors) ====
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon
~
!!! error TS2304: Cannot find name 'a'.
~
!!! error TS2304: Cannot find name 'c'.
~
!!! error TS8010: Type annotations can only be used in TypeScript files.
~
!!! error TS2304: Cannot find name 'd'.
~
!!! error TS2304: Cannot find name 'f'.

==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts (4 errors) ====
a ? (b) : c => (d) : e => f
~
!!! error TS2304: Cannot find name 'a'.
~
!!! error TS2304: Cannot find name 'c'.
~
!!! error TS2304: Cannot find name 'd'.
~
!!! error TS2304: Cannot find name 'f'.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts] ////

//// [fileJs.js]
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon

//// [fileTs.ts]
a ? (b) : c => (d) : e => f


//// [fileJs.js]
a ? function (b) { return (d); } : function (e) { return f; }; // Not legal JS; "Unexpected token ':'" at last colon
//// [fileTs.js]
a ? function (b) { return (d); } : function (e) { return f; };
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js ===
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon
>b : Symbol(b, Decl(fileJs.js, 0, 5))
>c : Symbol(c)
>e : Symbol(e, Decl(fileJs.js, 0, 20))

=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts ===
a ? (b) : c => (d) : e => f
>b : Symbol(b, Decl(fileTs.ts, 0, 5))
>c : Symbol(c)
>e : Symbol(e, Decl(fileTs.ts, 0, 20))

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js ===
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon
>a ? (b) : c => (d) : e => f : (b: any) => c
>a : any
>(b) : c => (d) : (b: any) => c
>b : any
>(d) : any
>d : any
>e => f : (e: any) => any
>e : any
>f : any

=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts ===
a ? (b) : c => (d) : e => f
>a ? (b) : c => (d) : e => f : (b: any) => c
>a : any
>(b) : c => (d) : (b: any) => c
>b : any
>(d) : any
>d : any
>e => f : (e: any) => any
>e : any
>f : any

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,1): error TS2304: Cannot find name 'a'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,11): error TS2304: Cannot find name 'c'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,11): error TS8010: Type annotations can only be used in TypeScript files.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,17): error TS2304: Cannot find name 'd'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,27): error TS2304: Cannot find name 'f'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,1): error TS2304: Cannot find name 'a'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,11): error TS2304: Cannot find name 'c'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,17): error TS2304: Cannot find name 'd'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,27): error TS2304: Cannot find name 'f'.


==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js (5 errors) ====
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon
~
!!! error TS2304: Cannot find name 'a'.
~
!!! error TS2304: Cannot find name 'c'.
~
!!! error TS8010: Type annotations can only be used in TypeScript files.
~
!!! error TS2304: Cannot find name 'd'.
~
!!! error TS2304: Cannot find name 'f'.

==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts (4 errors) ====
a ? (b) : c => (d) : e => f
~
!!! error TS2304: Cannot find name 'a'.
~
!!! error TS2304: Cannot find name 'c'.
~
!!! error TS2304: Cannot find name 'd'.
~
!!! error TS2304: Cannot find name 'f'.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts] ////

//// [fileJs.js]
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon

//// [fileTs.ts]
a ? (b) : c => (d) : e => f


//// [fileJs.js]
a ? (b) => (d) : e => f; // Not legal JS; "Unexpected token ':'" at last colon
//// [fileTs.js]
a ? (b) => (d) : e => f;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js ===
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon
>b : Symbol(b, Decl(fileJs.js, 0, 5))
>c : Symbol(c)
>e : Symbol(e, Decl(fileJs.js, 0, 20))

=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts ===
a ? (b) : c => (d) : e => f
>b : Symbol(b, Decl(fileTs.ts, 0, 5))
>c : Symbol(c)
>e : Symbol(e, Decl(fileTs.ts, 0, 20))

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js ===
a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon
>a ? (b) : c => (d) : e => f : (b: any) => c
>a : any
>(b) : c => (d) : (b: any) => c
>b : any
>(d) : any
>d : any
>e => f : (e: any) => any
>e : any
>f : any

=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts ===
a ? (b) : c => (d) : e => f
>a ? (b) : c => (d) : e => f : (b: any) => c
>a : any
>(b) : c => (d) : (b: any) => c
>b : any
>(d) : any
>d : any
>e => f : (e: any) => any
>e : any
>f : any

This file was deleted.

8 changes: 0 additions & 8 deletions tests/baselines/reference/parserArrowFunctionExpression10.js

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions tests/baselines/reference/parserArrowFunctionExpression10.types

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,1): error TS2304: Cannot find name 'a'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,5): error TS2304: Cannot find name 'b'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,9): error TS2304: Cannot find name 'c'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,14): error TS2304: Cannot find name 'd'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,24): error TS2304: Cannot find name 'f'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,1): error TS2304: Cannot find name 'a'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,5): error TS2304: Cannot find name 'b'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,9): error TS2304: Cannot find name 'c'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,14): error TS2304: Cannot find name 'd'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,24): error TS2304: Cannot find name 'f'.


==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js (5 errors) ====
a ? b ? c : (d) : e => f // Legal JS
~
!!! error TS2304: Cannot find name 'a'.
~
!!! error TS2304: Cannot find name 'b'.
~
!!! error TS2304: Cannot find name 'c'.
~
!!! error TS2304: Cannot find name 'd'.
~
!!! error TS2304: Cannot find name 'f'.

==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts (5 errors) ====
a ? b ? c : (d) : e => f
~
!!! error TS2304: Cannot find name 'a'.
~
!!! error TS2304: Cannot find name 'b'.
~
!!! error TS2304: Cannot find name 'c'.
~
!!! error TS2304: Cannot find name 'd'.
~
!!! error TS2304: Cannot find name 'f'.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts] ////

//// [fileJs.js]
a ? b ? c : (d) : e => f // Legal JS

//// [fileTs.ts]
a ? b ? c : (d) : e => f


//// [fileJs.js]
a ? b ? c : (d) : function (e) { return f; }; // Legal JS
//// [fileTs.js]
a ? b ? c : (d) : function (e) { return f; };
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js ===
a ? b ? c : (d) : e => f // Legal JS
>e : Symbol(e, Decl(fileJs.js, 0, 17))

=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts ===
a ? b ? c : (d) : e => f
>e : Symbol(e, Decl(fileTs.ts, 0, 17))

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js ===
a ? b ? c : (d) : e => f // Legal JS
>a ? b ? c : (d) : e => f : any
>a : any
>b ? c : (d) : any
>b : any
>c : any
>(d) : any
>d : any
>e => f : (e: any) => any
>e : any
>f : any

=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts ===
a ? b ? c : (d) : e => f
>a ? b ? c : (d) : e => f : any
>a : any
>b ? c : (d) : any
>b : any
>c : any
>(d) : any
>d : any
>e => f : (e: any) => any
>e : any
>f : any

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,1): error TS2304: Cannot find name 'a'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,5): error TS2304: Cannot find name 'b'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,9): error TS2304: Cannot find name 'c'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,14): error TS2304: Cannot find name 'd'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js(1,24): error TS2304: Cannot find name 'f'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,1): error TS2304: Cannot find name 'a'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,5): error TS2304: Cannot find name 'b'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,9): error TS2304: Cannot find name 'c'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,14): error TS2304: Cannot find name 'd'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts(1,24): error TS2304: Cannot find name 'f'.


==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js (5 errors) ====
a ? b ? c : (d) : e => f // Legal JS
~
!!! error TS2304: Cannot find name 'a'.
~
!!! error TS2304: Cannot find name 'b'.
~
!!! error TS2304: Cannot find name 'c'.
~
!!! error TS2304: Cannot find name 'd'.
~
!!! error TS2304: Cannot find name 'f'.

==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts (5 errors) ====
a ? b ? c : (d) : e => f
~
!!! error TS2304: Cannot find name 'a'.
~
!!! error TS2304: Cannot find name 'b'.
~
!!! error TS2304: Cannot find name 'c'.
~
!!! error TS2304: Cannot find name 'd'.
~
!!! error TS2304: Cannot find name 'f'.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts] ////

//// [fileJs.js]
a ? b ? c : (d) : e => f // Legal JS

//// [fileTs.ts]
a ? b ? c : (d) : e => f


//// [fileJs.js]
a ? b ? c : (d) : e => f; // Legal JS
//// [fileTs.js]
a ? b ? c : (d) : e => f;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileJs.js ===
a ? b ? c : (d) : e => f // Legal JS
>e : Symbol(e, Decl(fileJs.js, 0, 17))

=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/fileTs.ts ===
a ? b ? c : (d) : e => f
>e : Symbol(e, Decl(fileTs.ts, 0, 17))

Loading