Merge pull request #3225 from hzoo/cp-semi

`babylon`: throw parse error if class properties do not have a semico…
This commit is contained in:
Sebastian McKenzie 2016-01-06 15:22:37 +00:00
commit 6c79639801
5 changed files with 18 additions and 2 deletions

View File

@ -595,7 +595,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) {
@ -747,7 +747,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"]
}