added check to disallow super.private variable access and test case added (#10472)
* 🚀 added check to disallow super.private variable access and test case added * ♻️ change the other linting change back to how it was * ♻️ change the other linting change back to how it was * ♻️ added newline at the end test output.json file * ♻️ changed the linting style to the way it was * ♻️ updated error message, removed super private member access test cases from whitelist of flow and test 262 suite * ♻️ added newline in output.json
This commit is contained in:
committed by
Nicolò Ribaudo
parent
46c70ad734
commit
b7333ea97a
@@ -655,6 +655,12 @@ export default class ExpressionParser extends LValParser {
|
||||
node.object = base;
|
||||
node.property = this.parseMaybePrivateName();
|
||||
node.computed = false;
|
||||
if (
|
||||
node.property.type === "PrivateName" &&
|
||||
node.object.type === "Super"
|
||||
) {
|
||||
this.raise(startPos, "Private fields can't be accessed on super");
|
||||
}
|
||||
if (state.optionalChainMember) {
|
||||
node.optional = false;
|
||||
return this.finishNode(node, "OptionalMemberExpression");
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class A extends B {
|
||||
#x;
|
||||
|
||||
method() {
|
||||
super.#x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
"classPrivateProperties"
|
||||
],
|
||||
"throws": "Private fields can't be accessed on super (5:4)"
|
||||
}
|
||||
Reference in New Issue
Block a user