class private methods and properties: should not allow spaces between # and identifier (#8756)
This commit is contained in:
parent
36d12b5969
commit
850bc1d3dd
@ -923,7 +923,19 @@ export default class ExpressionParser extends LValParser {
|
|||||||
if (isPrivate) {
|
if (isPrivate) {
|
||||||
this.expectOnePlugin(["classPrivateProperties", "classPrivateMethods"]);
|
this.expectOnePlugin(["classPrivateProperties", "classPrivateMethods"]);
|
||||||
const node = this.startNode();
|
const node = this.startNode();
|
||||||
|
const columnHashEnd = this.state.end;
|
||||||
this.next();
|
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);
|
node.id = this.parseIdentifier(true);
|
||||||
return this.finishNode(node, "PrivateName");
|
return this.finishNode(node, "PrivateName");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -0,0 +1,5 @@
|
|||||||
|
class Spaces {
|
||||||
|
# wrongSpaces() {
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"throws": "Unexpected space between # and identifier (2:5)",
|
||||||
|
"plugins": ["classPrivateMethods"]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
class Spaces {
|
||||||
|
# wrongSpaces;
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"throws": "Unexpected space between # and identifier (2:5)",
|
||||||
|
"plugins": ["classPrivateMethods"]
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user