raise syntax error on declaration of private method, and add syntax tests for private fields

This commit is contained in:
Erik Krogh Kristensen
2020-02-03 16:00:25 +01:00
parent 183dd68d6a
commit e3189aaa47
6 changed files with 43 additions and 18 deletions

View File

@@ -3238,6 +3238,9 @@ public class Parser {
if (pi.kind.equals("set") && node.getValue().hasRest())
this.raiseRecoverable(params.get(params.size() - 1), "Setter cannot use rest params");
}
if (pi.key instanceof Identifier && ((Identifier)pi.key).getName().startsWith("#")) {
raiseRecoverable(pi.key, "Only fields, not methods, can be declared private.");
}
return node;
}