Skip to content

Commit 2e5a42d

Browse files
MaxGraeydcodeIO
authored andcommitted
Fix unexpected TS1005 in tryParseSignature (AssemblyScript#149)
1 parent 188b4e4 commit 2e5a42d

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/parser.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,14 @@ export class Parser extends DiagnosticEmitter {
650650
}
651651
} while (tn.skip(Token.COMMA));
652652
if (!tn.skip(Token.CLOSEPAREN)) {
653-
this.error(
654-
DiagnosticCode._0_expected,
655-
tn.range(), ")"
656-
);
653+
if (isSignature) {
654+
this.error(
655+
DiagnosticCode._0_expected,
656+
tn.range(), ")"
657+
);
658+
} else {
659+
tn.reset(state);
660+
}
657661
this.tryParseSignatureIsSignature = isSignature;
658662
return null;
659663
}

tests/parser/var.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ var e;
88

99
// 1155: 'const' declarations must be initialized.
1010
const f: i32;
11+
12+
const t = 0 < (c / 10);

tests/parser/var.ts.fixture.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ const c: i32 = 0;
44
var d = 2;
55
var e;
66
const f: i32;
7+
const t = 0 < (c / 10);
78
// ERROR 1110: "Type expected." in var.ts:7:5
89
// ERROR 1155: "'const' declarations must be initialized." in var.ts:10:6

0 commit comments

Comments
 (0)