mirror of
https://github.com/tc39/test262.git
synced 2025-10-16 21:38:47 +02:00
* Adding case where PrivateName is used inside computed property. * Adding proper description to early errors on usage of undeclared private names inside computed property.
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
/*---
|
|
description: PrivateName of a class is visible in its ComputetProperty scope
|
|
esid: prod-ClassTail
|
|
info: |
|
|
ClassTail : ClassHeritage { ClassBody }
|
|
1. Let lex be the LexicalEnvironment of the running execution context.
|
|
2. Let classScope be NewDeclarativeEnvironment(lex).
|
|
3. Let classScopeEnvRec be classScope's EnvironmentRecord.
|
|
...
|
|
15. Set the running execution context's LexicalEnvironment to classScope.
|
|
16. Set the running execution context's PrivateEnvironment to classPrivateEnvironment.
|
|
...
|
|
27. For each ClassElement e in order from elements
|
|
a. If IsStatic of e is false, then
|
|
i. Let field be the result of ClassElementEvaluation for e with arguments proto and false.
|
|
...
|
|
features: [class-fields-private, class]
|
|
---*/
|
|
|
|
assert.throws(TypeError, function() {
|
|
class C {
|
|
[this.#f] = 'Test262';
|
|
#f = 'foo';
|
|
}
|
|
}, 'access to a not defined private field in object should throw a TypeError');
|
|
|