| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/logical-assignment-private/and.case |
| 3 |
// - src/logical-assignment-private/default/getter-setter-short-circuit.template |
| 4 |
/*--- |
| 5 |
description: Logical-and assignment with target being a private reference (to an accessor property with getter and setter (short-circuit version)) |
| 6 |
esid: sec-assignment-operators-runtime-semantics-evaluation |
| 7 |
features: [class-fields-private, logical-assignment-operators] |
| 8 |
flags: [generated] |
| 9 |
info: | |
| 10 |
sec-property-accessors-runtime-semantics-evaluation |
| 11 |
MemberExpression : MemberExpression `.` PrivateIdentifier |
| 12 |
|
| 13 |
1. Let _baseReference_ be the result of evaluating |MemberExpression|. |
| 14 |
2. Let _baseValue_ be ? GetValue(_baseReference_). |
| 15 |
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. |
| 16 |
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). |
| 17 |
|
| 18 |
PutValue (V, W) |
| 19 |
... |
| 20 |
5.b. If IsPrivateReference(_V_) is *true*, then |
| 21 |
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). |
| 22 |
|
| 23 |
PrivateSet (O, P, value) |
| 24 |
... |
| 25 |
5.a. Assert: _entry_.[[Kind]] is ~accessor~. |
| 26 |
... |
| 27 |
5.c. Let _setter_ be _entry_.[[Set]]. |
| 28 |
d. Perform ? Call(_setter_, _O_, « _value_ »). |
| 29 |
|
| 30 |
|
| 31 |
sec-assignment-operators-runtime-semantics-evaluation |
| 32 |
AssignmentExpression : LeftHandSideExpression &&= AssignmentExpression |
| 33 |
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. |
| 34 |
2. Let _lval_ be ? GetValue(_lref_). |
| 35 |
3. Let _lbool_ be ! ToBoolean(_lval_). |
| 36 |
4. If _lbool_ is *false*, return _lval_. |
| 37 |
... |
| 38 |
7. Perform ? PutValue(_lref_, _rval_). |
| 39 |
8. Return _rval_. |
| 40 |
---*/ |
| 41 |
|
| 42 |
|
| 43 |
function doNotCall() { |
| 44 |
throw new Test262Error("The right-hand side should not be evaluated"); |
| 45 |
} |
| 46 |
|
| 47 |
class C { |
| 48 |
setterWasCalled = false; |
| 49 |
get #field() { |
| 50 |
return false; |
| 51 |
} |
| 52 |
set #field(value) { |
| 53 |
this.setterWasCalled = true; |
| 54 |
} |
| 55 |
compoundAssignment() { |
| 56 |
return this.#field &&= doNotCall(); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
const o = new C(); |
| 61 |
assert.sameValue(o.compoundAssignment(), false, "The expression should evaluate to the short-circuit value"); |
| 62 |
assert(!o.setterWasCalled, "The setter should not be called"); |
| 63 |
|
| 64 |
reportCompare(0, 0); |