Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Commit

Permalink
Merge pull request #648 from Qantas94Heavy/private-field-no-shorthand
Browse files Browse the repository at this point in the history
Remove private field shorthand
  • Loading branch information
jridgewell committed Jul 27, 2017
2 parents 0bc9d78 + 42d5dbe commit 6821cfb
Show file tree
Hide file tree
Showing 12 changed files with 2,623 additions and 1,952 deletions.
21 changes: 6 additions & 15 deletions src/parser/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,12 @@ export default class ExpressionParser extends LValParser {

if (arg.type === "Identifier") {
this.raise(node.start, "Deleting local variable in strict mode");
} else if (this.hasPlugin("classPrivateProperties")) {
if (
arg.type === "PrivateName" ||
(arg.type === "MemberExpression" &&
arg.property.type === "PrivateName")
) {
this.raise(node.start, "Deleting a private field is not allowed");
}
} else if (
this.hasPlugin("classPrivateProperties") &&
arg.type === "MemberExpression" &&
arg.property.type === "PrivateName"
) {
this.raise(node.start, "Deleting a private field is not allowed");
}
}

Expand Down Expand Up @@ -747,13 +745,6 @@ export default class ExpressionParser extends LValParser {
this.takeDecorators(node);
return this.parseClass(node, false);

case tt.hash:
if (this.hasPlugin("classPrivateProperties")) {
return this.parseMaybePrivateName();
} else {
throw this.unexpected();
}

case tt._new:
return this.parseNew();

Expand Down
2 changes: 0 additions & 2 deletions src/parser/lval.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export default class LValParser extends NodeUtils {
if (node) {
switch (node.type) {
case "Identifier":
case "PrivateName":
case "ObjectPattern":
case "ArrayPattern":
case "AssignmentPattern":
Expand Down Expand Up @@ -300,7 +299,6 @@ export default class LValParser extends NodeUtils {
contextDescription: string,
): void {
switch (expr.type) {
case "PrivateName":
case "Identifier":
this.checkReservedWord(expr.name, expr.start, false, true);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"throws": "Unexpected token, expected ; (3:9)",
"throws": "Unexpected token (3:3)",
"plugins": ["classProperties", "classPrivateProperties"]
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"throws": "Deleting a private field is not allowed (4:4)",
"throws": "Unexpected token (4:11)",
"plugins": [
"classProperties",
"classPrivateProperties"
Expand Down
Loading

0 comments on commit 6821cfb

Please sign in to comment.