Skip to content

Commit e4fe50c

Browse files
authored
Fix incorrect parser error assumption in semicolon handling leading to incremental parser brokenness (#48067)
1 parent 7191875 commit e4fe50c

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

Diff for: src/compiler/parser.ts

+1-12
Original file line numberDiff line numberDiff line change
@@ -1681,19 +1681,8 @@ namespace ts {
16811681
return;
16821682
}
16831683

1684-
// If an initializer was parsed but there is still an error in finding the next semicolon,
1685-
// we generally know there was an error already reported in the initializer...
1686-
// class Example { a = new Map([), ) }
1687-
// ~
16881684
if (initializer) {
1689-
// ...unless we've found the start of a block after a property declaration, in which
1690-
// case we can know that regardless of the initializer we should complain on the block.
1691-
// class Example { a = 0 {} }
1692-
// ~
1693-
if (token() === SyntaxKind.OpenBraceToken) {
1694-
parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(SyntaxKind.SemicolonToken));
1695-
}
1696-
1685+
parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(SyntaxKind.SemicolonToken));
16971686
return;
16981687
}
16991688

Diff for: tests/baselines/reference/parser0_004152.errors.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,28): error TS2304: Cannot find name 'DisplayPosition'.
22
tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,45): error TS1137: Expression or comma expected.
3-
tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,46): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
3+
tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,46): error TS1005: ';' expected.
44
tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,49): error TS1005: ';' expected.
55
tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,51): error TS2300: Duplicate identifier '3'.
66
tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(2,52): error TS1005: ';' expected.
@@ -41,7 +41,7 @@ tests/cases/conformance/parser/ecmascript5/Fuzz/parser0_004152.ts(3,25): error T
4141
~
4242
!!! error TS1137: Expression or comma expected.
4343
~
44-
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
44+
!!! error TS1005: ';' expected.
4545
~
4646
!!! error TS1005: ';' expected.
4747
~
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @target: esnext
4+
// @lib: es2015
5+
// @strict: true
6+
7+
//// class C {
8+
//// map = new Set<string, number>/*$*/
9+
////
10+
//// foo() {
11+
////
12+
//// }
13+
//// }
14+
15+
goTo.marker('$');
16+
edit.insert('()');
17+
verify.getSyntacticDiagnostics([]);

0 commit comments

Comments
 (0)