Skip to content

Commit 2f282a7

Browse files
Merge pull request #5566 from jeffreymorlan/fix5444
Fix issue #5444
2 parents 38215c6 + ed453dd commit 2f282a7

File tree

4 files changed

+104
-1
lines changed

4 files changed

+104
-1
lines changed

src/compiler/checker.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -11439,7 +11439,9 @@ namespace ts {
1143911439
seen = c === node;
1144011440
}
1144111441
});
11442-
if (subsequentNode) {
11442+
// We may be here because of some extra junk between overloads that could not be parsed into a valid node.
11443+
// In this case the subsequent node is not really consecutive (.pos !== node.end), and we must ignore it here.
11444+
if (subsequentNode && subsequentNode.pos === node.end) {
1144311445
if (subsequentNode.kind === node.kind) {
1144411446
const errorNode: Node = (<FunctionLikeDeclaration>subsequentNode).name || subsequentNode;
1144511447
// TODO(jfreeman): These are methods, so handle computed name case
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
tests/cases/compiler/overloadConsecutiveness.ts(3,10): error TS2391: Function implementation is missing or not immediately following the declaration.
2+
tests/cases/compiler/overloadConsecutiveness.ts(3,14): error TS1144: '{' or ';' expected.
3+
tests/cases/compiler/overloadConsecutiveness.ts(3,25): error TS2391: Function implementation is missing or not immediately following the declaration.
4+
tests/cases/compiler/overloadConsecutiveness.ts(4,10): error TS2391: Function implementation is missing or not immediately following the declaration.
5+
tests/cases/compiler/overloadConsecutiveness.ts(4,14): error TS1144: '{' or ';' expected.
6+
tests/cases/compiler/overloadConsecutiveness.ts(5,10): error TS2391: Function implementation is missing or not immediately following the declaration.
7+
tests/cases/compiler/overloadConsecutiveness.ts(5,17): error TS1128: Declaration or statement expected.
8+
tests/cases/compiler/overloadConsecutiveness.ts(5,28): error TS2391: Function implementation is missing or not immediately following the declaration.
9+
tests/cases/compiler/overloadConsecutiveness.ts(8,2): error TS2391: Function implementation is missing or not immediately following the declaration.
10+
tests/cases/compiler/overloadConsecutiveness.ts(8,6): error TS1144: '{' or ';' expected.
11+
tests/cases/compiler/overloadConsecutiveness.ts(8,8): error TS2391: Function implementation is missing or not immediately following the declaration.
12+
tests/cases/compiler/overloadConsecutiveness.ts(9,2): error TS2391: Function implementation is missing or not immediately following the declaration.
13+
tests/cases/compiler/overloadConsecutiveness.ts(9,6): error TS1144: '{' or ';' expected.
14+
tests/cases/compiler/overloadConsecutiveness.ts(10,2): error TS2391: Function implementation is missing or not immediately following the declaration.
15+
tests/cases/compiler/overloadConsecutiveness.ts(10,9): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
16+
tests/cases/compiler/overloadConsecutiveness.ts(10,11): error TS2391: Function implementation is missing or not immediately following the declaration.
17+
18+
19+
==== tests/cases/compiler/overloadConsecutiveness.ts (16 errors) ====
20+
// Making sure compiler won't break with declarations that are consecutive in the AST but not consecutive in the source. Syntax errors intentional.
21+
22+
function f1(), function f1();
23+
~~
24+
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
25+
~
26+
!!! error TS1144: '{' or ';' expected.
27+
~~
28+
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
29+
function f2(), function f2() {}
30+
~~
31+
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
32+
~
33+
!!! error TS1144: '{' or ';' expected.
34+
function f3() {}, function f3();
35+
~~
36+
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
37+
~
38+
!!! error TS1128: Declaration or statement expected.
39+
~~
40+
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
41+
42+
class C {
43+
m1(), m1();
44+
~~
45+
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
46+
~
47+
!!! error TS1144: '{' or ';' expected.
48+
~~
49+
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
50+
m2(), m2() {}
51+
~~
52+
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
53+
~
54+
!!! error TS1144: '{' or ';' expected.
55+
m3() {}, m3();
56+
~~
57+
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
58+
~
59+
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
60+
~~
61+
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
62+
}
63+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//// [overloadConsecutiveness.ts]
2+
// Making sure compiler won't break with declarations that are consecutive in the AST but not consecutive in the source. Syntax errors intentional.
3+
4+
function f1(), function f1();
5+
function f2(), function f2() {}
6+
function f3() {}, function f3();
7+
8+
class C {
9+
m1(), m1();
10+
m2(), m2() {}
11+
m3() {}, m3();
12+
}
13+
14+
15+
//// [overloadConsecutiveness.js]
16+
// Making sure compiler won't break with declarations that are consecutive in the AST but not consecutive in the source. Syntax errors intentional.
17+
function f2() { }
18+
function f3() { }
19+
var C = (function () {
20+
function C() {
21+
}
22+
C.prototype.m1 = ;
23+
C.prototype.m2 = ;
24+
C.prototype.m2 = function () { };
25+
C.prototype.m3 = function () { };
26+
return C;
27+
})();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Making sure compiler won't break with declarations that are consecutive in the AST but not consecutive in the source. Syntax errors intentional.
2+
3+
function f1(), function f1();
4+
function f2(), function f2() {}
5+
function f3() {}, function f3();
6+
7+
class C {
8+
m1(), m1();
9+
m2(), m2() {}
10+
m3() {}, m3();
11+
}

0 commit comments

Comments
 (0)