Handle private access chained on an optional chain (#11248)

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
This commit is contained in:
Justin Ridgewell
2020-05-26 16:16:50 -04:00
committed by Nicolò Ribaudo
parent 852520eff5
commit bda759ac3d
104 changed files with 6964 additions and 37 deletions

View File

@@ -502,7 +502,8 @@ export default class ExpressionParser extends LValParser {
if (arg.type === "Identifier") {
this.raise(node.start, Errors.StrictDelete);
} else if (
arg.type === "MemberExpression" &&
(arg.type === "MemberExpression" ||
arg.type === "OptionalMemberExpression") &&
arg.property.type === "PrivateName"
) {
this.raise(node.start, Errors.DeletePrivateField);
@@ -616,8 +617,6 @@ export default class ExpressionParser extends LValParser {
node.object = base;
node.property = computed
? this.parseExpression()
: optional
? this.parseIdentifier(true)
: this.parseMaybePrivateName(true);
node.computed = computed;