| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/compound-assignment-private/div.case |
| 3 |
// - src/compound-assignment-private/default/method.template |
| 4 |
/*--- |
| 5 |
description: Compound division assignment with target being a private reference (to a private method) |
| 6 |
esid: sec-assignment-operators-runtime-semantics-evaluation |
| 7 |
features: [class-fields-private] |
| 8 |
flags: [generated] |
| 9 |
info: | |
| 10 |
sec-assignment-operators-runtime-semantics-evaluation |
| 11 |
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression |
| 12 |
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. |
| 13 |
2. Let _lval_ be ? GetValue(_lref_). |
| 14 |
... |
| 15 |
7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). |
| 16 |
8. Perform ? PutValue(_lref_, _r_). |
| 17 |
9. Return _r_. |
| 18 |
|
| 19 |
sec-property-accessors-runtime-semantics-evaluation |
| 20 |
MemberExpression : MemberExpression `.` PrivateIdentifier |
| 21 |
|
| 22 |
1. Let _baseReference_ be the result of evaluating |MemberExpression|. |
| 23 |
2. Let _baseValue_ be ? GetValue(_baseReference_). |
| 24 |
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. |
| 25 |
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). |
| 26 |
|
| 27 |
PutValue (V, W) |
| 28 |
... |
| 29 |
5.b. If IsPrivateReference(_V_) is *true*, then |
| 30 |
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). |
| 31 |
|
| 32 |
PrivateSet (O, P, value) |
| 33 |
... |
| 34 |
4. Else if _entry_.[[Kind]] is ~method~, then |
| 35 |
a. Throw a *TypeError* exception. |
| 36 |
|
| 37 |
---*/ |
| 38 |
|
| 39 |
|
| 40 |
class C { |
| 41 |
#privateMethod() {} |
| 42 |
compoundAssignment() { |
| 43 |
return this.#privateMethod /= 1; |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
const o = new C(); |
| 48 |
assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); |
| 49 |
|
| 50 |
reportCompare(0, 0); |