babylon: throw parse error if class properties do not have a semicolon (fixes T6873)
This commit is contained in:
parent
326e157e5d
commit
e849c62144
@ -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");
|
||||
};
|
||||
|
||||
|
||||
3
test/fixtures/experimental/class-properties/semicolons-required-with-value/actual.js
vendored
Normal file
3
test/fixtures/experimental/class-properties/semicolons-required-with-value/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
class A {
|
||||
asdf = 1
|
||||
}
|
||||
4
test/fixtures/experimental/class-properties/semicolons-required-with-value/options.json
vendored
Normal file
4
test/fixtures/experimental/class-properties/semicolons-required-with-value/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "A semicolon is required after a class property (3:0)",
|
||||
"plugins": ["classProperties"]
|
||||
}
|
||||
3
test/fixtures/experimental/class-properties/semicolons-required-without-value/actual.js
vendored
Normal file
3
test/fixtures/experimental/class-properties/semicolons-required-without-value/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
class A {
|
||||
asdf
|
||||
}
|
||||
4
test/fixtures/experimental/class-properties/semicolons-required-without-value/options.json
vendored
Normal file
4
test/fixtures/experimental/class-properties/semicolons-required-without-value/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "A semicolon is required after a class property (3:0)",
|
||||
"plugins": ["classProperties"]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user