mirror of https://github.com/tc39/test262.git
Fix tests for private reference with logical assignment
There were three things wrong with the 'and', 'or', and 'nullish' tests that I added as part of #2940: 1. They were in the wrong folder (should be expressions/logical-assignment, not expressions/compound-assignment) 2. The tests for ||= and ??= on readonly accessor properties were incorrect. These assignments would short-circuit if the getter returned 1 as it previously did, so PutValue would not throw. 3. The tests for ||= and ??= on private methods were invalid, as a method always evaluates to true in a boolean context, and is not nullish, so these would always short-circuit. I've removed the invalid private method cases, fixed the readonly accessor cases, and added new templates to test the short-circuit behaviour as well as the non-short-circuit behaviour. Closes: #3413
This commit is contained in:
parent
ec39db5877
commit
615a2eb9a1
|
@ -1,16 +0,0 @@
|
|||
// Copyright 2022 Igalia S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
template: default
|
||||
desc: Compound logical-and assignment with target being a private reference
|
||||
---*/
|
||||
|
||||
//- lhs
|
||||
true
|
||||
//- operator
|
||||
&&=
|
||||
//- rhs
|
||||
false
|
||||
//- result
|
||||
false
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright 2022 Igalia S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
template: default
|
||||
desc: Compound nullish-coalescing assignment with target being a private reference
|
||||
---*/
|
||||
|
||||
//- lhs
|
||||
null
|
||||
//- operator
|
||||
??=
|
||||
//- rhs
|
||||
1
|
||||
//- result
|
||||
1
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright 2022 Igalia S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
template: default
|
||||
desc: Compound logical-or assignment with target being a private reference
|
||||
---*/
|
||||
|
||||
//- lhs
|
||||
false
|
||||
//- operator
|
||||
||=
|
||||
//- rhs
|
||||
true
|
||||
//- result
|
||||
true
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright 2022 Igalia S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
templates:
|
||||
- default/data-property.template
|
||||
- default/data-property-short-circuit.template
|
||||
- default/getter-setter.template
|
||||
- default/getter-setter-short-circuit.template
|
||||
- default/getter.template
|
||||
- default/getter-short-circuit.template
|
||||
- default/method.template
|
||||
desc: Logical-and assignment with target being a private reference
|
||||
info: |
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression &&= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *false*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
//- lhs
|
||||
true
|
||||
//- operator
|
||||
&&=
|
||||
//- rhs
|
||||
false
|
||||
//- result
|
||||
false
|
||||
//- short-circuit-lhs
|
||||
false
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright 2021 the V8 project authors; 2022 Igalia S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
path: language/expressions/logical-assignment/left-hand-side-private-reference-data-property-short-circuit-
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
3. If _entry_.[[Kind]] is ~field~, then
|
||||
a. Set _entry_.[[Value]] to _value_.
|
||||
name: to a field (short-circuit version)
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
---*/
|
||||
|
||||
function doNotCall() {
|
||||
throw new Test262Error("The right-hand side should not be evaluated");
|
||||
}
|
||||
|
||||
class C {
|
||||
#field = /*{short-circuit-lhs}*/;
|
||||
compoundAssignment() {
|
||||
return this.#field /*{operator}*/ doNotCall();
|
||||
}
|
||||
fieldValue() {
|
||||
return this.#field;
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.sameValue(o.compoundAssignment(), /*{short-circuit-lhs}*/, "The expression should evaluate to the short-circuit value");
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright 2021 the V8 project authors; 2022 Igalia S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
path: language/expressions/logical-assignment/left-hand-side-private-reference-data-property-
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
3. If _entry_.[[Kind]] is ~field~, then
|
||||
a. Set _entry_.[[Value]] to _value_.
|
||||
name: to a field
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
---*/
|
||||
|
||||
class C {
|
||||
#field = /*{lhs}*/;
|
||||
compoundAssignment() {
|
||||
return this.#field /*{operator}*/ /*{rhs}*/;
|
||||
}
|
||||
fieldValue() {
|
||||
return this.#field;
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.sameValue(o.compoundAssignment(), /*{result}*/, "The expression should evaluate to the result");
|
||||
assert.sameValue(o.fieldValue(), /*{result}*/, "PutValue should store the result in the private reference");
|
|
@ -0,0 +1,50 @@
|
|||
// Copyright 2021 the V8 project authors; 2022 Igalia S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
path: language/expressions/logical-assignment/left-hand-side-private-reference-accessor-property-short-circuit-
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
5.a. Assert: _entry_.[[Kind]] is ~accessor~.
|
||||
...
|
||||
5.c. Let _setter_ be _entry_.[[Set]].
|
||||
d. Perform ? Call(_setter_, _O_, « _value_ »).
|
||||
name: to an accessor property with getter and setter (short-circuit version)
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
---*/
|
||||
|
||||
function doNotCall() {
|
||||
throw new Test262Error("The right-hand side should not be evaluated");
|
||||
}
|
||||
|
||||
class C {
|
||||
setterWasCalled = false;
|
||||
get #field() {
|
||||
return /*{short-circuit-lhs}*/;
|
||||
}
|
||||
set #field(value) {
|
||||
this.setterWasCalled = true;
|
||||
}
|
||||
compoundAssignment() {
|
||||
return this.#field /*{operator}*/ doNotCall();
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.sameValue(o.compoundAssignment(), /*{short-circuit-lhs}*/, "The expression should evaluate to the short-circuit value");
|
||||
assert(!o.setterWasCalled, "The setter should not be called");
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright 2021 the V8 project authors; 2022 Igalia S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
path: language/expressions/logical-assignment/left-hand-side-private-reference-accessor-property-
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
5.a. Assert: _entry_.[[Kind]] is ~accessor~.
|
||||
...
|
||||
5.c. Let _setter_ be _entry_.[[Set]].
|
||||
d. Perform ? Call(_setter_, _O_, « _value_ »).
|
||||
name: to an accessor property with getter and setter
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
---*/
|
||||
|
||||
class C {
|
||||
#setterCalledWith;
|
||||
get #field() {
|
||||
return /*{lhs}*/;
|
||||
}
|
||||
set #field(value) {
|
||||
this.#setterCalledWith = value;
|
||||
}
|
||||
compoundAssignment() {
|
||||
return this.#field /*{operator}*/ /*{rhs}*/;
|
||||
}
|
||||
setterCalledWithValue() {
|
||||
return this.#setterCalledWith;
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.sameValue(o.compoundAssignment(), /*{result}*/, "The expression should evaluate to the result");
|
||||
assert.sameValue(o.setterCalledWithValue(), /*{result}*/, "PutValue should call the setter with the result");
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright 2021 the V8 project authors; 2022 Igalia S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
path: language/expressions/logical-assignment/left-hand-side-private-reference-readonly-accessor-property-short-circuit-
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
5.a. Assert: _entry_.[[Kind]] is ~accessor~.
|
||||
b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception.
|
||||
name: to an accessor property with getter (short-circuit version)
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
---*/
|
||||
|
||||
function doNotCall() {
|
||||
throw new Test262Error("The right-hand side should not be evaluated");
|
||||
}
|
||||
|
||||
class C {
|
||||
get #field() {
|
||||
return /*{short-circuit-lhs}*/;
|
||||
}
|
||||
compoundAssignment() {
|
||||
return this.#field /*{operator}*/ doNotCall();
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.sameValue(o.compoundAssignment(), /*{short-circuit-lhs}*/, "The expression should evaluate to the short-circuit value");
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2021 the V8 project authors; 2022 Igalia S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
path: language/expressions/logical-assignment/left-hand-side-private-reference-readonly-accessor-property-
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
5.a. Assert: _entry_.[[Kind]] is ~accessor~.
|
||||
b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception.
|
||||
name: to an accessor property with getter
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
---*/
|
||||
|
||||
class C {
|
||||
get #field() {
|
||||
return /*{lhs}*/;
|
||||
}
|
||||
compoundAssignment() {
|
||||
return this.#field /*{operator}*/ /*{rhs}*/;
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter");
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright 2021 the V8 project authors; 2022 Igalia S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
path: language/expressions/logical-assignment/left-hand-side-private-reference-method-short-circuit-
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
4. Else if _entry_.[[Kind]] is ~method~, then
|
||||
a. Throw a *TypeError* exception.
|
||||
name: to a private method (short-circuit version)
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
---*/
|
||||
|
||||
function doNotCall() {
|
||||
throw new Test262Error("The right-hand side should not be evaluated");
|
||||
}
|
||||
|
||||
class C {
|
||||
#privateMethod() {}
|
||||
compoundAssignment() {
|
||||
return this.#privateMethod /*{operator}*/ doNotCall();
|
||||
}
|
||||
getPrivateMethodFunctionObject() {
|
||||
return this.#privateMethod;
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.sameValue(o.compoundAssignment(), o.getPrivateMethodFunctionObject(), "The expression should evaluate to the short-circuit value");
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2021 the V8 project authors; 2022 Igalia S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
path: language/expressions/logical-assignment/left-hand-side-private-reference-method-
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
4. Else if _entry_.[[Kind]] is ~method~, then
|
||||
a. Throw a *TypeError* exception.
|
||||
name: to a private method
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
---*/
|
||||
|
||||
class C {
|
||||
#privateMethod() {}
|
||||
compoundAssignment() {
|
||||
return this.#privateMethod /*{operator}*/ 1;
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference");
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright 2022 Igalia S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
templates:
|
||||
- default/data-property.template
|
||||
- default/data-property-short-circuit.template
|
||||
- default/getter-setter.template
|
||||
- default/getter-setter-short-circuit.template
|
||||
- default/getter.template
|
||||
- default/getter-short-circuit.template
|
||||
- default/method-short-circuit.template
|
||||
desc: Nullish-coalescing assignment with target being a private reference
|
||||
info: |
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ??= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. If _lval_ is neither *undefined* nor *null*, return _lval_.
|
||||
...
|
||||
6. Perform ? PutValue(_lref_, _rval_).
|
||||
7. Return _rval_.
|
||||
---*/
|
||||
|
||||
//- lhs
|
||||
null
|
||||
//- operator
|
||||
??=
|
||||
//- rhs
|
||||
1
|
||||
//- result
|
||||
1
|
||||
//- short-circuit-lhs
|
||||
1
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright 2022 Igalia S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
templates:
|
||||
- default/data-property.template
|
||||
- default/data-property-short-circuit.template
|
||||
- default/getter-setter.template
|
||||
- default/getter-setter-short-circuit.template
|
||||
- default/getter.template
|
||||
- default/getter-short-circuit.template
|
||||
- default/method-short-circuit.template
|
||||
desc: Logical-or assignment with target being a private reference
|
||||
info: |
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ||= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *true*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
//- lhs
|
||||
false
|
||||
//- operator
|
||||
||=
|
||||
//- rhs
|
||||
true
|
||||
//- result
|
||||
true
|
||||
//- short-circuit-lhs
|
||||
true
|
|
@ -1,21 +1,12 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/compound-assignment-private/and.case
|
||||
// - src/compound-assignment-private/default/getter-setter.template
|
||||
// - src/logical-assignment-private/and.case
|
||||
// - src/logical-assignment-private/default/getter-setter.template
|
||||
/*---
|
||||
description: Compound logical-and assignment with target being a private reference (to an accessor property with getter and setter)
|
||||
description: Logical-and assignment with target being a private reference (to an accessor property with getter and setter)
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private]
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
...
|
||||
7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_).
|
||||
8. Perform ? PutValue(_lref_, _r_).
|
||||
9. Return _r_.
|
||||
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
|
@ -36,6 +27,16 @@ info: |
|
|||
5.c. Let _setter_ be _entry_.[[Set]].
|
||||
d. Perform ? Call(_setter_, _O_, « _value_ »).
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression &&= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *false*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
|
@ -1,21 +1,12 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/compound-assignment-private/nullish.case
|
||||
// - src/compound-assignment-private/default/getter-setter.template
|
||||
// - src/logical-assignment-private/nullish.case
|
||||
// - src/logical-assignment-private/default/getter-setter.template
|
||||
/*---
|
||||
description: Compound nullish-coalescing assignment with target being a private reference (to an accessor property with getter and setter)
|
||||
description: Nullish-coalescing assignment with target being a private reference (to an accessor property with getter and setter)
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private]
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
...
|
||||
7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_).
|
||||
8. Perform ? PutValue(_lref_, _r_).
|
||||
9. Return _r_.
|
||||
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
|
@ -36,6 +27,15 @@ info: |
|
|||
5.c. Let _setter_ be _entry_.[[Set]].
|
||||
d. Perform ? Call(_setter_, _O_, « _value_ »).
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ??= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. If _lval_ is neither *undefined* nor *null*, return _lval_.
|
||||
...
|
||||
6. Perform ? PutValue(_lref_, _rval_).
|
||||
7. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
|
@ -1,21 +1,12 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/compound-assignment-private/or.case
|
||||
// - src/compound-assignment-private/default/getter-setter.template
|
||||
// - src/logical-assignment-private/or.case
|
||||
// - src/logical-assignment-private/default/getter-setter.template
|
||||
/*---
|
||||
description: Compound logical-or assignment with target being a private reference (to an accessor property with getter and setter)
|
||||
description: Logical-or assignment with target being a private reference (to an accessor property with getter and setter)
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private]
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
...
|
||||
7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_).
|
||||
8. Perform ? PutValue(_lref_, _r_).
|
||||
9. Return _r_.
|
||||
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
|
@ -36,6 +27,16 @@ info: |
|
|||
5.c. Let _setter_ be _entry_.[[Set]].
|
||||
d. Perform ? Call(_setter_, _O_, « _value_ »).
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ||= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *true*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/logical-assignment-private/and.case
|
||||
// - src/logical-assignment-private/default/getter-setter-short-circuit.template
|
||||
/*---
|
||||
description: Logical-and assignment with target being a private reference (to an accessor property with getter and setter (short-circuit version))
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
5.a. Assert: _entry_.[[Kind]] is ~accessor~.
|
||||
...
|
||||
5.c. Let _setter_ be _entry_.[[Set]].
|
||||
d. Perform ? Call(_setter_, _O_, « _value_ »).
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression &&= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *false*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
||||
function doNotCall() {
|
||||
throw new Test262Error("The right-hand side should not be evaluated");
|
||||
}
|
||||
|
||||
class C {
|
||||
setterWasCalled = false;
|
||||
get #field() {
|
||||
return false;
|
||||
}
|
||||
set #field(value) {
|
||||
this.setterWasCalled = true;
|
||||
}
|
||||
compoundAssignment() {
|
||||
return this.#field &&= doNotCall();
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.sameValue(o.compoundAssignment(), false, "The expression should evaluate to the short-circuit value");
|
||||
assert(!o.setterWasCalled, "The setter should not be called");
|
|
@ -0,0 +1,61 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/logical-assignment-private/nullish.case
|
||||
// - src/logical-assignment-private/default/getter-setter-short-circuit.template
|
||||
/*---
|
||||
description: Nullish-coalescing assignment with target being a private reference (to an accessor property with getter and setter (short-circuit version))
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
5.a. Assert: _entry_.[[Kind]] is ~accessor~.
|
||||
...
|
||||
5.c. Let _setter_ be _entry_.[[Set]].
|
||||
d. Perform ? Call(_setter_, _O_, « _value_ »).
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ??= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. If _lval_ is neither *undefined* nor *null*, return _lval_.
|
||||
...
|
||||
6. Perform ? PutValue(_lref_, _rval_).
|
||||
7. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
||||
function doNotCall() {
|
||||
throw new Test262Error("The right-hand side should not be evaluated");
|
||||
}
|
||||
|
||||
class C {
|
||||
setterWasCalled = false;
|
||||
get #field() {
|
||||
return 1;
|
||||
}
|
||||
set #field(value) {
|
||||
this.setterWasCalled = true;
|
||||
}
|
||||
compoundAssignment() {
|
||||
return this.#field ??= doNotCall();
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.sameValue(o.compoundAssignment(), 1, "The expression should evaluate to the short-circuit value");
|
||||
assert(!o.setterWasCalled, "The setter should not be called");
|
|
@ -0,0 +1,62 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/logical-assignment-private/or.case
|
||||
// - src/logical-assignment-private/default/getter-setter-short-circuit.template
|
||||
/*---
|
||||
description: Logical-or assignment with target being a private reference (to an accessor property with getter and setter (short-circuit version))
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
5.a. Assert: _entry_.[[Kind]] is ~accessor~.
|
||||
...
|
||||
5.c. Let _setter_ be _entry_.[[Set]].
|
||||
d. Perform ? Call(_setter_, _O_, « _value_ »).
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ||= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *true*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
||||
function doNotCall() {
|
||||
throw new Test262Error("The right-hand side should not be evaluated");
|
||||
}
|
||||
|
||||
class C {
|
||||
setterWasCalled = false;
|
||||
get #field() {
|
||||
return true;
|
||||
}
|
||||
set #field(value) {
|
||||
this.setterWasCalled = true;
|
||||
}
|
||||
compoundAssignment() {
|
||||
return this.#field ||= doNotCall();
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.sameValue(o.compoundAssignment(), true, "The expression should evaluate to the short-circuit value");
|
||||
assert(!o.setterWasCalled, "The setter should not be called");
|
|
@ -1,21 +1,12 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/compound-assignment-private/and.case
|
||||
// - src/compound-assignment-private/default/data-property.template
|
||||
// - src/logical-assignment-private/and.case
|
||||
// - src/logical-assignment-private/default/data-property.template
|
||||
/*---
|
||||
description: Compound logical-and assignment with target being a private reference (to a field)
|
||||
description: Logical-and assignment with target being a private reference (to a field)
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private]
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
...
|
||||
7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_).
|
||||
8. Perform ? PutValue(_lref_, _r_).
|
||||
9. Return _r_.
|
||||
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
|
@ -34,6 +25,16 @@ info: |
|
|||
3. If _entry_.[[Kind]] is ~field~, then
|
||||
a. Set _entry_.[[Value]] to _value_.
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression &&= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *false*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
|
@ -1,21 +1,12 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/compound-assignment-private/nullish.case
|
||||
// - src/compound-assignment-private/default/data-property.template
|
||||
// - src/logical-assignment-private/nullish.case
|
||||
// - src/logical-assignment-private/default/data-property.template
|
||||
/*---
|
||||
description: Compound nullish-coalescing assignment with target being a private reference (to a field)
|
||||
description: Nullish-coalescing assignment with target being a private reference (to a field)
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private]
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
...
|
||||
7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_).
|
||||
8. Perform ? PutValue(_lref_, _r_).
|
||||
9. Return _r_.
|
||||
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
|
@ -34,6 +25,15 @@ info: |
|
|||
3. If _entry_.[[Kind]] is ~field~, then
|
||||
a. Set _entry_.[[Value]] to _value_.
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ??= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. If _lval_ is neither *undefined* nor *null*, return _lval_.
|
||||
...
|
||||
6. Perform ? PutValue(_lref_, _rval_).
|
||||
7. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
|
@ -1,21 +1,12 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/compound-assignment-private/or.case
|
||||
// - src/compound-assignment-private/default/data-property.template
|
||||
// - src/logical-assignment-private/or.case
|
||||
// - src/logical-assignment-private/default/data-property.template
|
||||
/*---
|
||||
description: Compound logical-or assignment with target being a private reference (to a field)
|
||||
description: Logical-or assignment with target being a private reference (to a field)
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private]
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
...
|
||||
7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_).
|
||||
8. Perform ? PutValue(_lref_, _r_).
|
||||
9. Return _r_.
|
||||
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
|
@ -34,6 +25,16 @@ info: |
|
|||
3. If _entry_.[[Kind]] is ~field~, then
|
||||
a. Set _entry_.[[Value]] to _value_.
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ||= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *true*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/logical-assignment-private/and.case
|
||||
// - src/logical-assignment-private/default/data-property-short-circuit.template
|
||||
/*---
|
||||
description: Logical-and assignment with target being a private reference (to a field (short-circuit version))
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
3. If _entry_.[[Kind]] is ~field~, then
|
||||
a. Set _entry_.[[Value]] to _value_.
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression &&= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *false*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
||||
function doNotCall() {
|
||||
throw new Test262Error("The right-hand side should not be evaluated");
|
||||
}
|
||||
|
||||
class C {
|
||||
#field = false;
|
||||
compoundAssignment() {
|
||||
return this.#field &&= doNotCall();
|
||||
}
|
||||
fieldValue() {
|
||||
return this.#field;
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.sameValue(o.compoundAssignment(), false, "The expression should evaluate to the short-circuit value");
|
|
@ -0,0 +1,55 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/logical-assignment-private/nullish.case
|
||||
// - src/logical-assignment-private/default/data-property-short-circuit.template
|
||||
/*---
|
||||
description: Nullish-coalescing assignment with target being a private reference (to a field (short-circuit version))
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
3. If _entry_.[[Kind]] is ~field~, then
|
||||
a. Set _entry_.[[Value]] to _value_.
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ??= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. If _lval_ is neither *undefined* nor *null*, return _lval_.
|
||||
...
|
||||
6. Perform ? PutValue(_lref_, _rval_).
|
||||
7. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
||||
function doNotCall() {
|
||||
throw new Test262Error("The right-hand side should not be evaluated");
|
||||
}
|
||||
|
||||
class C {
|
||||
#field = 1;
|
||||
compoundAssignment() {
|
||||
return this.#field ??= doNotCall();
|
||||
}
|
||||
fieldValue() {
|
||||
return this.#field;
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.sameValue(o.compoundAssignment(), 1, "The expression should evaluate to the short-circuit value");
|
|
@ -0,0 +1,56 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/logical-assignment-private/or.case
|
||||
// - src/logical-assignment-private/default/data-property-short-circuit.template
|
||||
/*---
|
||||
description: Logical-or assignment with target being a private reference (to a field (short-circuit version))
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
3. If _entry_.[[Kind]] is ~field~, then
|
||||
a. Set _entry_.[[Value]] to _value_.
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ||= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *true*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
||||
function doNotCall() {
|
||||
throw new Test262Error("The right-hand side should not be evaluated");
|
||||
}
|
||||
|
||||
class C {
|
||||
#field = true;
|
||||
compoundAssignment() {
|
||||
return this.#field ||= doNotCall();
|
||||
}
|
||||
fieldValue() {
|
||||
return this.#field;
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.sameValue(o.compoundAssignment(), true, "The expression should evaluate to the short-circuit value");
|
|
@ -1,21 +1,12 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/compound-assignment-private/and.case
|
||||
// - src/compound-assignment-private/default/method.template
|
||||
// - src/logical-assignment-private/and.case
|
||||
// - src/logical-assignment-private/default/method.template
|
||||
/*---
|
||||
description: Compound logical-and assignment with target being a private reference (to a private method)
|
||||
description: Logical-and assignment with target being a private reference (to a private method)
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private]
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
...
|
||||
7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_).
|
||||
8. Perform ? PutValue(_lref_, _r_).
|
||||
9. Return _r_.
|
||||
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
|
@ -34,6 +25,16 @@ info: |
|
|||
4. Else if _entry_.[[Kind]] is ~method~, then
|
||||
a. Throw a *TypeError* exception.
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression &&= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *false*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
|
@ -1,21 +1,12 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/compound-assignment-private/nullish.case
|
||||
// - src/compound-assignment-private/default/method.template
|
||||
// - src/logical-assignment-private/nullish.case
|
||||
// - src/logical-assignment-private/default/method-short-circuit.template
|
||||
/*---
|
||||
description: Compound nullish-coalescing assignment with target being a private reference (to a private method)
|
||||
description: Nullish-coalescing assignment with target being a private reference (to a private method (short-circuit version))
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private]
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
...
|
||||
7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_).
|
||||
8. Perform ? PutValue(_lref_, _r_).
|
||||
9. Return _r_.
|
||||
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
|
@ -34,15 +25,31 @@ info: |
|
|||
4. Else if _entry_.[[Kind]] is ~method~, then
|
||||
a. Throw a *TypeError* exception.
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ??= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. If _lval_ is neither *undefined* nor *null*, return _lval_.
|
||||
...
|
||||
6. Perform ? PutValue(_lref_, _rval_).
|
||||
7. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
||||
function doNotCall() {
|
||||
throw new Test262Error("The right-hand side should not be evaluated");
|
||||
}
|
||||
|
||||
class C {
|
||||
#privateMethod() {}
|
||||
compoundAssignment() {
|
||||
return this.#privateMethod ??= 1;
|
||||
return this.#privateMethod ??= doNotCall();
|
||||
}
|
||||
getPrivateMethodFunctionObject() {
|
||||
return this.#privateMethod;
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference");
|
||||
assert.sameValue(o.compoundAssignment(), o.getPrivateMethodFunctionObject(), "The expression should evaluate to the short-circuit value");
|
|
@ -1,21 +1,12 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/compound-assignment-private/or.case
|
||||
// - src/compound-assignment-private/default/method.template
|
||||
// - src/logical-assignment-private/or.case
|
||||
// - src/logical-assignment-private/default/method-short-circuit.template
|
||||
/*---
|
||||
description: Compound logical-or assignment with target being a private reference (to a private method)
|
||||
description: Logical-or assignment with target being a private reference (to a private method (short-circuit version))
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private]
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
...
|
||||
7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_).
|
||||
8. Perform ? PutValue(_lref_, _r_).
|
||||
9. Return _r_.
|
||||
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
|
@ -34,15 +25,32 @@ info: |
|
|||
4. Else if _entry_.[[Kind]] is ~method~, then
|
||||
a. Throw a *TypeError* exception.
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ||= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *true*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
||||
function doNotCall() {
|
||||
throw new Test262Error("The right-hand side should not be evaluated");
|
||||
}
|
||||
|
||||
class C {
|
||||
#privateMethod() {}
|
||||
compoundAssignment() {
|
||||
return this.#privateMethod ||= 1;
|
||||
return this.#privateMethod ||= doNotCall();
|
||||
}
|
||||
getPrivateMethodFunctionObject() {
|
||||
return this.#privateMethod;
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference");
|
||||
assert.sameValue(o.compoundAssignment(), o.getPrivateMethodFunctionObject(), "The expression should evaluate to the short-circuit value");
|
|
@ -1,21 +1,12 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/compound-assignment-private/and.case
|
||||
// - src/compound-assignment-private/default/getter.template
|
||||
// - src/logical-assignment-private/and.case
|
||||
// - src/logical-assignment-private/default/getter.template
|
||||
/*---
|
||||
description: Compound logical-and assignment with target being a private reference (to an accessor property with getter)
|
||||
description: Logical-and assignment with target being a private reference (to an accessor property with getter)
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private]
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
...
|
||||
7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_).
|
||||
8. Perform ? PutValue(_lref_, _r_).
|
||||
9. Return _r_.
|
||||
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
|
@ -34,15 +25,25 @@ info: |
|
|||
5.a. Assert: _entry_.[[Kind]] is ~accessor~.
|
||||
b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception.
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression &&= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *false*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
||||
class C {
|
||||
get #field() {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
compoundAssignment() {
|
||||
return this.#field &&= 1;
|
||||
return this.#field &&= false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,12 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/compound-assignment-private/nullish.case
|
||||
// - src/compound-assignment-private/default/getter.template
|
||||
// - src/logical-assignment-private/nullish.case
|
||||
// - src/logical-assignment-private/default/getter.template
|
||||
/*---
|
||||
description: Compound nullish-coalescing assignment with target being a private reference (to an accessor property with getter)
|
||||
description: Nullish-coalescing assignment with target being a private reference (to an accessor property with getter)
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private]
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
...
|
||||
7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_).
|
||||
8. Perform ? PutValue(_lref_, _r_).
|
||||
9. Return _r_.
|
||||
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
|
@ -34,12 +25,21 @@ info: |
|
|||
5.a. Assert: _entry_.[[Kind]] is ~accessor~.
|
||||
b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception.
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ??= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. If _lval_ is neither *undefined* nor *null*, return _lval_.
|
||||
...
|
||||
6. Perform ? PutValue(_lref_, _rval_).
|
||||
7. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
||||
class C {
|
||||
get #field() {
|
||||
return 1;
|
||||
return null;
|
||||
}
|
||||
compoundAssignment() {
|
||||
return this.#field ??= 1;
|
|
@ -1,21 +1,12 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/compound-assignment-private/or.case
|
||||
// - src/compound-assignment-private/default/getter.template
|
||||
// - src/logical-assignment-private/or.case
|
||||
// - src/logical-assignment-private/default/getter.template
|
||||
/*---
|
||||
description: Compound logical-or assignment with target being a private reference (to an accessor property with getter)
|
||||
description: Logical-or assignment with target being a private reference (to an accessor property with getter)
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private]
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
...
|
||||
7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_).
|
||||
8. Perform ? PutValue(_lref_, _r_).
|
||||
9. Return _r_.
|
||||
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
|
@ -34,15 +25,25 @@ info: |
|
|||
5.a. Assert: _entry_.[[Kind]] is ~accessor~.
|
||||
b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception.
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ||= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *true*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
||||
class C {
|
||||
get #field() {
|
||||
return 1;
|
||||
return false;
|
||||
}
|
||||
compoundAssignment() {
|
||||
return this.#field ||= 1;
|
||||
return this.#field ||= true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/logical-assignment-private/and.case
|
||||
// - src/logical-assignment-private/default/getter-short-circuit.template
|
||||
/*---
|
||||
description: Logical-and assignment with target being a private reference (to an accessor property with getter (short-circuit version))
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
5.a. Assert: _entry_.[[Kind]] is ~accessor~.
|
||||
b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception.
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression &&= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *false*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
||||
function doNotCall() {
|
||||
throw new Test262Error("The right-hand side should not be evaluated");
|
||||
}
|
||||
|
||||
class C {
|
||||
get #field() {
|
||||
return false;
|
||||
}
|
||||
compoundAssignment() {
|
||||
return this.#field &&= doNotCall();
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.sameValue(o.compoundAssignment(), false, "The expression should evaluate to the short-circuit value");
|
|
@ -0,0 +1,54 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/logical-assignment-private/nullish.case
|
||||
// - src/logical-assignment-private/default/getter-short-circuit.template
|
||||
/*---
|
||||
description: Nullish-coalescing assignment with target being a private reference (to an accessor property with getter (short-circuit version))
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
5.a. Assert: _entry_.[[Kind]] is ~accessor~.
|
||||
b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception.
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ??= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. If _lval_ is neither *undefined* nor *null*, return _lval_.
|
||||
...
|
||||
6. Perform ? PutValue(_lref_, _rval_).
|
||||
7. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
||||
function doNotCall() {
|
||||
throw new Test262Error("The right-hand side should not be evaluated");
|
||||
}
|
||||
|
||||
class C {
|
||||
get #field() {
|
||||
return 1;
|
||||
}
|
||||
compoundAssignment() {
|
||||
return this.#field ??= doNotCall();
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.sameValue(o.compoundAssignment(), 1, "The expression should evaluate to the short-circuit value");
|
|
@ -0,0 +1,55 @@
|
|||
// This file was procedurally generated from the following sources:
|
||||
// - src/logical-assignment-private/or.case
|
||||
// - src/logical-assignment-private/default/getter-short-circuit.template
|
||||
/*---
|
||||
description: Logical-or assignment with target being a private reference (to an accessor property with getter (short-circuit version))
|
||||
esid: sec-assignment-operators-runtime-semantics-evaluation
|
||||
features: [class-fields-private, logical-assignment-operators]
|
||||
flags: [generated]
|
||||
info: |
|
||||
sec-property-accessors-runtime-semantics-evaluation
|
||||
MemberExpression : MemberExpression `.` PrivateIdentifier
|
||||
|
||||
1. Let _baseReference_ be the result of evaluating |MemberExpression|.
|
||||
2. Let _baseValue_ be ? GetValue(_baseReference_).
|
||||
3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|.
|
||||
4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_).
|
||||
|
||||
PutValue (V, W)
|
||||
...
|
||||
5.b. If IsPrivateReference(_V_) is *true*, then
|
||||
i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_).
|
||||
|
||||
PrivateSet (O, P, value)
|
||||
...
|
||||
5.a. Assert: _entry_.[[Kind]] is ~accessor~.
|
||||
b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception.
|
||||
|
||||
|
||||
sec-assignment-operators-runtime-semantics-evaluation
|
||||
AssignmentExpression : LeftHandSideExpression ||= AssignmentExpression
|
||||
1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
|
||||
2. Let _lval_ be ? GetValue(_lref_).
|
||||
3. Let _lbool_ be ! ToBoolean(_lval_).
|
||||
4. If _lbool_ is *true*, return _lval_.
|
||||
...
|
||||
7. Perform ? PutValue(_lref_, _rval_).
|
||||
8. Return _rval_.
|
||||
---*/
|
||||
|
||||
|
||||
function doNotCall() {
|
||||
throw new Test262Error("The right-hand side should not be evaluated");
|
||||
}
|
||||
|
||||
class C {
|
||||
get #field() {
|
||||
return true;
|
||||
}
|
||||
compoundAssignment() {
|
||||
return this.#field ||= doNotCall();
|
||||
}
|
||||
}
|
||||
|
||||
const o = new C();
|
||||
assert.sameValue(o.compoundAssignment(), true, "The expression should evaluate to the short-circuit value");
|
Loading…
Reference in New Issue