privatefieldset-evaluation-order-3.js (1000B)
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 Base { 20 constructor(o) { 21 return o; 22 } 23 } 24 25 class C extends Base { 26 #field; 27 28 m() { 29 var init = () => new C(this); 30 31 var object = { 32 get a() { 33 init(); 34 35 return "pass"; 36 } 37 }; 38 39 ({a: this.#field} = object); 40 41 assert.sameValue(this.#field, "pass"); 42 } 43 } 44 45 C.prototype.m.call({}); 46 47 reportCompare(0, 0);