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