Check for EOF on parse error in blocks, fixes #180

This commit is contained in:
dcodeIO 2018-07-21 03:11:33 +02:00
parent ccc019d853
commit 00fb45fcad
3 changed files with 14 additions and 6 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2386,6 +2386,7 @@ export class Parser extends DiagnosticEmitter {
let state = tn.mark(); let state = tn.mark();
let statement = this.parseStatement(tn, topLevel); let statement = this.parseStatement(tn, topLevel);
if (!statement) { if (!statement) {
if (tn.token == Token.ENDOFFILE) return null;
tn.reset(state); tn.reset(state);
this.skipStatement(tn); this.skipStatement(tn);
} else { } else {
@ -3176,10 +3177,17 @@ export class Parser extends DiagnosticEmitter {
return this.parseClassExpression(tn); return this.parseClassExpression(tn);
} }
default: { default: {
this.error( if (token == Token.ENDOFFILE) {
DiagnosticCode.Expression_expected, this.error(
tn.range() DiagnosticCode.Unexpected_end_of_text,
); tn.range(startPos)
);
} else {
this.error(
DiagnosticCode.Expression_expected,
tn.range()
);
}
return null; return null;
} }
} }