Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/privatefieldset-evaluation-order-2.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. Let v be ? GetV(value, propertyName).
14 3. ...
15
16 features: [class, class-fields-private]
17 ---*/
18
19 class C {
20 #field;
21
22 m() {
23 var object = {
24 get a() {
25 throw new Test262Error();
26 }
27 };
28
29 // The getter is executed before the check if the private field is present.
30 ({a: this.#field} = object);
31 }
32 }
33
34 assert.throws(Test262Error, function() {
35 C.prototype.m.call({});
36 });
37
38 reportCompare(0, 0);