babylon: throw parse error if class properties do not have a semicolon (fixes T6873)

This commit is contained in:
Henry Zhu 2015-12-30 13:09:01 -05:00
parent 326e157e5d
commit e849c62144
5 changed files with 18 additions and 2 deletions

View File

@ -594,7 +594,7 @@ pp.parseClass = function (node, isStatement, optionalId) {
};
pp.isClassProperty = function () {
return this.match(tt.eq) || this.isLineTerminator();
return this.match(tt.eq) || this.match(tt.semi) || this.canInsertSemicolon();
};
pp.parseClassBody = function (node) {
@ -746,7 +746,9 @@ pp.parseClassProperty = function (node) {
} else {
node.value = null;
}
this.semicolon();
if (!this.eat(tt.semi)) {
this.raise(this.state.start, "A semicolon is required after a class property");
}
return this.finishNode(node, "ClassProperty");
};

View File

@ -0,0 +1,3 @@
class A {
asdf = 1
}

View File

@ -0,0 +1,4 @@
{
"throws": "A semicolon is required after a class property (3:0)",
"plugins": ["classProperties"]
}

View File

@ -0,0 +1,3 @@
class A {
asdf
}

View File

@ -0,0 +1,4 @@
{
"throws": "A semicolon is required after a class property (3:0)",
"plugins": ["classProperties"]
}