Skip to content

Commit 7f639cc

Browse files
committed
Test:disable lookahead in isStartOfParameter
1 parent d3ce606 commit 7f639cc

8 files changed

+60
-22
lines changed

src/compiler/parser.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,12 +2238,6 @@ namespace ts {
22382238
isIdentifierOrPattern() ||
22392239
isModifierKind(token()) ||
22402240
token() === SyntaxKind.AtToken ||
2241-
// a jsdoc parameter can start directly with a type, but shouldn't look ahead
2242-
// in order to avoid confusion between parenthesized types and arrow functions
2243-
// eg
2244-
// declare function f(cb: function(number): void): void;
2245-
// vs
2246-
// f((n) => console.log(n));
22472241
isStartOfType(/*disableLookahead*/ true);
22482242
}
22492243

tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.errors.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,15): error TS1003: Identifier expected.
1+
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,12): error TS2304: Cannot find name 'a'.
2+
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,12): error TS2695: Left side of comma operator is unused and has no side effects.
23
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,16): error TS2304: Cannot find name 'b'.
34
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,16): error TS2695: Left side of comma operator is unused and has no side effects.
45
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,19): error TS2304: Cannot find name 'c'.
6+
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,23): error TS1005: ';' expected.
7+
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,26): error TS2304: Cannot find name 'a'.
58
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,28): error TS2304: Cannot find name 'b'.
69
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,30): error TS2304: Cannot find name 'c'.
710
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(2,12): error TS2695: Left side of comma operator is unused and has no side effects.
@@ -18,16 +21,22 @@ tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(4,17): error TS1005
1821
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(4,20): error TS2304: Cannot find name 'a'.
1922

2023

21-
==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts (18 errors) ====
24+
==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts (21 errors) ====
2225
var tt1 = (a, (b, c)) => a+b+c;
23-
~
24-
!!! error TS1003: Identifier expected.
26+
~
27+
!!! error TS2304: Cannot find name 'a'.
28+
~
29+
!!! error TS2695: Left side of comma operator is unused and has no side effects.
2530
~
2631
!!! error TS2304: Cannot find name 'b'.
2732
~
2833
!!! error TS2695: Left side of comma operator is unused and has no side effects.
2934
~
3035
!!! error TS2304: Cannot find name 'c'.
36+
~~
37+
!!! error TS1005: ';' expected.
38+
~
39+
!!! error TS2304: Cannot find name 'a'.
3140
~
3241
!!! error TS2304: Cannot find name 'b'.
3342
~

tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ var tt2 = ((a), b, c) => a+b+c;
55
var tt3 = ((a)) => a;
66

77
//// [fatarrowfunctionsOptionalArgsErrors2.js]
8-
var tt1 = function (a, ) {
9-
if ( === void 0) { = (b, c); }
10-
return a + b + c;
11-
};
8+
var tt1 = (a, (b, c));
9+
a + b + c;
1210
var tt2 = ((a), b, c);
1311
a + b + c;
1412
var tt3 = ((a));

tests/baselines/reference/parser512325.errors.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
1-
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,14): error TS1003: Identifier expected.
1+
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,11): error TS2304: Cannot find name 'a'.
2+
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,11): error TS2695: Left side of comma operator is unused and has no side effects.
23
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,15): error TS2304: Cannot find name 'b'.
34
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,15): error TS2695: Left side of comma operator is unused and has no side effects.
45
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,18): error TS2304: Cannot find name 'c'.
6+
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,22): error TS1005: ';' expected.
7+
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,25): error TS2304: Cannot find name 'a'.
58
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,27): error TS2304: Cannot find name 'b'.
69
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,29): error TS2304: Cannot find name 'c'.
710

811

9-
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts (6 errors) ====
12+
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts (9 errors) ====
1013
var tt = (a, (b, c)) => a+b+c;
11-
~
12-
!!! error TS1003: Identifier expected.
14+
~
15+
!!! error TS2304: Cannot find name 'a'.
16+
~
17+
!!! error TS2695: Left side of comma operator is unused and has no side effects.
1318
~
1419
!!! error TS2304: Cannot find name 'b'.
1520
~
1621
!!! error TS2695: Left side of comma operator is unused and has no side effects.
1722
~
1823
!!! error TS2304: Cannot find name 'c'.
24+
~~
25+
!!! error TS1005: ';' expected.
26+
~
27+
!!! error TS2304: Cannot find name 'a'.
1928
~
2029
!!! error TS2304: Cannot find name 'b'.
2130
~

tests/baselines/reference/parser512325.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22
var tt = (a, (b, c)) => a+b+c;
33

44
//// [parser512325.js]
5-
var tt = function (a, ) {
6-
if ( === void 0) { = (b, c); }
7-
return a + b + c;
8-
};
5+
var tt = (a, (b, c));
6+
a + b + c;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts(1,2): error TS2304: Cannot find name 'bar'.
2+
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts(1,6): error TS2304: Cannot find name 'x'.
3+
4+
5+
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts (2 errors) ====
6+
(bar(x,
7+
~~~
8+
!!! error TS2304: Cannot find name 'bar'.
9+
~
10+
!!! error TS2304: Cannot find name 'x'.
11+
() => {},
12+
() => {}
13+
)
14+
)
15+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//// [parserArrowFunctionExpression5.ts]
2+
(bar(x,
3+
() => {},
4+
() => {}
5+
)
6+
)
7+
8+
9+
//// [parserArrowFunctionExpression5.js]
10+
(bar(x, function () { }, function () { }));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(bar(x,
2+
() => {},
3+
() => {}
4+
)
5+
)

0 commit comments

Comments
 (0)