class private methods and properties: should not allow spaces between # and identifier (#8756)

This commit is contained in:
Bruno Macabeus 2018-10-02 23:31:06 -03:00 committed by Logan Smyth
parent 36d12b5969
commit 850bc1d3dd
5 changed files with 28 additions and 0 deletions

View File

@ -923,7 +923,19 @@ export default class ExpressionParser extends LValParser {
if (isPrivate) {
this.expectOnePlugin(["classPrivateProperties", "classPrivateMethods"]);
const node = this.startNode();
const columnHashEnd = this.state.end;
this.next();
const columnIdentifierStart = this.state.start;
const spacesBetweenHashAndIdentifier =
columnIdentifierStart - columnHashEnd;
if (spacesBetweenHashAndIdentifier != 0) {
this.raise(
columnIdentifierStart,
"Unexpected space between # and identifier",
);
}
node.id = this.parseIdentifier(true);
return this.finishNode(node, "PrivateName");
} else {

View File

@ -0,0 +1,5 @@
class Spaces {
# wrongSpaces() {
return fail();
}
}

View File

@ -0,0 +1,4 @@
{
"throws": "Unexpected space between # and identifier (2:5)",
"plugins": ["classPrivateMethods"]
}

View File

@ -0,0 +1,3 @@
class Spaces {
# wrongSpaces;
}

View File

@ -0,0 +1,4 @@
{
"throws": "Unexpected space between # and identifier (2:5)",
"plugins": ["classPrivateMethods"]
}