Add stray semicolons as class elements
This commit is contained in:
parent
dac747dfa9
commit
9f7cb55264
3
acorn.js
3
acorn.js
@ -2524,6 +2524,8 @@
|
|||||||
classBody.body = [];
|
classBody.body = [];
|
||||||
expect(_braceL);
|
expect(_braceL);
|
||||||
while (!eat(_braceR)) {
|
while (!eat(_braceR)) {
|
||||||
|
while (eat(_semi));
|
||||||
|
if (tokType === _braceR) continue;
|
||||||
var method = startNode();
|
var method = startNode();
|
||||||
var isGenerator = eat(_star);
|
var isGenerator = eat(_star);
|
||||||
parsePropertyName(method);
|
parsePropertyName(method);
|
||||||
@ -2546,7 +2548,6 @@
|
|||||||
}
|
}
|
||||||
method.value = parseMethod(isGenerator);
|
method.value = parseMethod(isGenerator);
|
||||||
classBody.body.push(finishNode(method, "MethodDefinition"));
|
classBody.body.push(finishNode(method, "MethodDefinition"));
|
||||||
eat(_semi);
|
|
||||||
}
|
}
|
||||||
node.body = finishNode(classBody, "ClassBody");
|
node.body = finishNode(classBody, "ClassBody");
|
||||||
return finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
|
return finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
|
||||||
|
|||||||
@ -8859,6 +8859,42 @@ test("class A { foo() {} get foo() {} }",{
|
|||||||
locations: true
|
locations: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("class Semicolon { ; }", {
|
||||||
|
type: "Program",
|
||||||
|
loc: {
|
||||||
|
start: {line: 1, column: 0},
|
||||||
|
end: {line: 1, column: 21}
|
||||||
|
},
|
||||||
|
body: [{
|
||||||
|
type: "ClassDeclaration",
|
||||||
|
loc: {
|
||||||
|
start: {line: 1, column: 0},
|
||||||
|
end: {line: 1, column: 21}
|
||||||
|
},
|
||||||
|
id: {
|
||||||
|
type: "Identifier",
|
||||||
|
loc: {
|
||||||
|
start: {line: 1, column: 6},
|
||||||
|
end: {line: 1, column: 15}
|
||||||
|
},
|
||||||
|
name: "Semicolon"
|
||||||
|
},
|
||||||
|
superClass: null,
|
||||||
|
body: {
|
||||||
|
type: "ClassBody",
|
||||||
|
loc: {
|
||||||
|
start: {line: 1, column: 16},
|
||||||
|
end: {line: 1, column: 21}
|
||||||
|
},
|
||||||
|
body: []
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}, {
|
||||||
|
ecmaVersion: 6,
|
||||||
|
ranges: true,
|
||||||
|
locations: true
|
||||||
|
});
|
||||||
|
|
||||||
// ES6: Computed Properties
|
// ES6: Computed Properties
|
||||||
|
|
||||||
test("({[x]: 10})", {
|
test("({[x]: 10})", {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user