Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/privatefieldset-evaluation-order-1.js

raw
1 // Copyright (C) 2021 André Bargull. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: >
6 Evaluation order when resolving private fields.
7 esid: sec-runtime-semantics-keyeddestructuringassignmentevaluation
8 info: |
9 13.15.5.6 Runtime Semantics: KeyedDestructuringAssignmentEvaluation
10 1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an ArrayLiteral, then
11 a. Let lref be the result of evaluating DestructuringAssignmentTarget.
12 b. ReturnIfAbrupt(lref).
13 2. ...
14
15 9.1.1.3.4 GetThisBinding ( )
16 1. Assert: envRec.[[ThisBindingStatus]] is not lexical.
17 2. If envRec.[[ThisBindingStatus]] is uninitialized, throw a ReferenceError exception.
18 3. ...
19
20 features: [class, class-fields-private]
21 ---*/
22
23 class C extends class {} {
24 #field;
25
26 constructor() {
27 var init = () => super();
28
29 var object = {
30 get a() {
31 init();
32 }
33 };
34
35 // Accessing |this| should throw a ReferenceError before there's an attempt
36 // to invoke the getter.
37 ({a: this.#field} = object);
38 }
39 }
40
41 assert.throws(ReferenceError, function() {
42 new C();
43 });
44
45 reportCompare(0, 0);