Skip to content

Commit 4d44f07

Browse files
committed
Fix some missed cases passing the boolean around
1 parent 3e950f5 commit 4d44f07

File tree

5 files changed

+15
-21
lines changed

5 files changed

+15
-21
lines changed

src/compiler/parser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4175,7 +4175,7 @@ namespace ts {
41754175
// If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
41764176
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
41774177
// with AssignmentExpression if we see one.
4178-
const arrowExpression = tryParseParenthesizedArrowFunctionExpression(parsingConditionalExpression) || tryParseAsyncSimpleArrowFunctionExpression();
4178+
const arrowExpression = tryParseParenthesizedArrowFunctionExpression(parsingConditionalExpression) || tryParseAsyncSimpleArrowFunctionExpression(parsingConditionalExpression);
41794179
if (arrowExpression) {
41804180
return arrowExpression;
41814181
}
@@ -4206,7 +4206,7 @@ namespace ts {
42064206
// Note: we call reScanGreaterToken so that we get an appropriately merged token
42074207
// for cases like `> > =` becoming `>>=`
42084208
if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) {
4209-
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos);
4209+
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(parsingConditionalExpression), pos);
42104210
}
42114211

42124212
// It wasn't an assignment or a lambda. This is a conditional expression:
@@ -4574,7 +4574,7 @@ namespace ts {
45744574
const lastToken = token();
45754575
const equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken);
45764576
const body = (lastToken === SyntaxKind.EqualsGreaterThanToken || lastToken === SyntaxKind.OpenBraceToken)
4577-
? parseArrowFunctionExpressionBody(some(modifiers, isAsyncModifier))
4577+
? parseArrowFunctionExpressionBody(some(modifiers, isAsyncModifier), parsingConditionalExpression)
45784578
: parseIdentifier();
45794579

45804580
const node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
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,17): error TS2304: Cannot find name 'd'.
2+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts(1,13): error TS2304: Cannot find name 'c'.
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.
54

65

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

tests/baselines/reference/parserArrowFunctionExpression12.js

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

44

55
//// [parserArrowFunctionExpression12.js]
6-
a ? function (b) { return function (c) { return e; }; }
7-
:
8-
;
6+
a ? function (b) { return (c); } : function (d) { return e; };
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts ===
22
a ? (b) => (c): d => e
33
>b : Symbol(b, Decl(parserArrowFunctionExpression12.ts, 0, 5))
4-
>c : Symbol(c, Decl(parserArrowFunctionExpression12.ts, 0, 12))
5-
>d : Symbol(d)
4+
>d : Symbol(d, Decl(parserArrowFunctionExpression12.ts, 0, 15))
65

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts ===
22
a ? (b) => (c): d => e
3-
>a ? (b) => (c): d => e : any
3+
>a ? (b) => (c): d => e : (b: any) => any
44
>a : any
5-
>(b) => (c): d => e : (b: any) => (c: any) => d
5+
>(b) => (c) : (b: any) => any
66
>b : any
7-
>(c): d => e : (c: any) => d
7+
>(c) : any
88
>c : any
9+
>d => e : (d: any) => any
10+
>d : any
911
>e : any
1012

11-
> : any
12-

0 commit comments

Comments
 (0)