Debian Codegraph @

js/src/tests/test262/language/expressions/logical-assignment/left-hand-side-private-reference-readonly-accessor-property-nullish.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/logical-assignment-private/nullish.case
3 // - src/logical-assignment-private/default/getter.template
4 /*---
5 description: Nullish-coalescing assignment with target being a private reference (to an accessor property with getter)
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 b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception.
27
28
29 sec-assignment-operators-runtime-semantics-evaluation
30 AssignmentExpression : LeftHandSideExpression ??= AssignmentExpression
31 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
32 2. Let _lval_ be ? GetValue(_lref_).
33 3. If _lval_ is neither *undefined* nor *null*, return _lval_.
34 ...
35 6. Perform ? PutValue(_lref_, _rval_).
36 7. Return _rval_.
37 ---*/
38
39
40 class C {
41 get #field() {
42 return null;
43 }
44 compoundAssignment() {
45 return this.#field ??= 1;
46 }
47 }
48
49 const o = new C();
50 assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter");
51
52 reportCompare(0, 0);