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 d2f5a409da
7 changed files with 21 additions and 5 deletions

View File

@ -5,5 +5,5 @@ class Child extends Parent {
scopedFunctionWithThis = () => {
this.name = {};
}
};
}

View File

@ -1,7 +1,7 @@
call(class {
static test = true
static test = true;
});
export default class {
static test = true
static test = true;
};

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,4 @@
{
"throws": "A semicolon is required after a class property (3:0)",
"plugins": ["classProperties"]
}