mirror of
https://github.com/tc39/test262.git
synced 2025-07-22 21:45:04 +02:00
Undefined private name access in computed property keys should throw TypeError (#2390)
Refs: https://github.com/tc39/proposal-class-fields/pull/269
This commit is contained in:
parent
a898fe9826
commit
13882715c3
@ -13,6 +13,8 @@ info: |
|
|||||||
8. If ClassBodyopt is present, then
|
8. If ClassBodyopt is present, then
|
||||||
a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt,
|
a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt,
|
||||||
i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true).
|
i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true).
|
||||||
|
ii. Let privateName be NewPrivateName(dn).
|
||||||
|
iii. Perform ! classPrivateEnvRec.InitializeBinding(dn, dn).
|
||||||
...
|
...
|
||||||
15. Set the running execution context's LexicalEnvironment to classScope.
|
15. Set the running execution context's LexicalEnvironment to classScope.
|
||||||
16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment.
|
16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment.
|
||||||
@ -22,35 +24,26 @@ info: |
|
|||||||
i. Let field be the result of ClassElementEvaluation for e with arguments proto and false.
|
i. Let field be the result of ClassElementEvaluation for e with arguments proto and false.
|
||||||
...
|
...
|
||||||
|
|
||||||
MemberExpression : MemberExpression . PrivateIdentifier
|
|
||||||
...
|
|
||||||
5. Return MakePrivateReference(bv, fieldNameString).
|
|
||||||
|
|
||||||
MakePrivateReference ( baseValue, privateIdentifier )
|
|
||||||
...
|
|
||||||
2. Let privateNameBinding be ? ResolveBinding(privateIdentifier, env).
|
|
||||||
3. Let privateName be GetValue(privateNameBinding).
|
|
||||||
...
|
|
||||||
|
|
||||||
GetValue ( V )
|
GetValue ( V )
|
||||||
...
|
...
|
||||||
6. Else,
|
5. If IsPropertyReference(V), then
|
||||||
a. Assert: base is an Environment Record.
|
|
||||||
b. Return ? base.GetBindingValue(GetReferencedName(V), IsStrictReference(V)).
|
|
||||||
|
|
||||||
GetBindingValue ( N, S )
|
|
||||||
...
|
...
|
||||||
3. If the binding for N in envRec is an uninitialized binding, throw a ReferenceError exception.
|
b. If IsPrivateReference(V), then
|
||||||
|
i. Return ? PrivateFieldGet(GetReferencedName(V), base).
|
||||||
|
|
||||||
|
PrivateFieldGet ( P, O )
|
||||||
|
...
|
||||||
|
4. If entry is empty, throw a TypeError exception.
|
||||||
...
|
...
|
||||||
|
|
||||||
features: [class-fields-private, class-fields-public, class]
|
features: [class-fields-private, class-fields-public, class]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
assert.throws(ReferenceError, function() {
|
assert.throws(TypeError, function() {
|
||||||
class C {
|
class C {
|
||||||
[self.#f] = 'Test262';
|
[self.#f] = 'Test262';
|
||||||
#f = 'foo';
|
#f = 'foo';
|
||||||
}
|
}
|
||||||
}, 'access to a not defined private field in object should throw a ReferenceError');
|
}, 'access to a not defined private field in object should throw a TypeError');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user