Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (C) 2026 Sergey Rubanov. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-assignment-operators-runtime-semantics-evaluation
description: >
ToPropertyKey is called only once on the key of base[prop] += value.
info: |
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression

1. Let leftRef be ? Evaluation of LeftHandSideExpression.
...
3. Let leftValue be ? GetValue(leftRef).
...
9. Perform ? PutValue(leftRef, result).

GetValue ( refRecord )

...
3. If IsPropertyReference(refRecord) is true, then
...
c. If refRecord.[[ReferencedName]] is not a property key, then
i. Set refRecord.[[ReferencedName]] to ? ToPropertyKey(refRecord.[[ReferencedName]]).

PutValue ( refRecord, value )

...
3. If IsPropertyReference(refRecord) is true, then
...
c. If refRecord.[[ReferencedName]] is not a property key, then
i. Set refRecord.[[ReferencedName]] to ? ToPropertyKey(refRecord.[[ReferencedName]]).
---*/

var count = 0;
var prop = {
toString: function() {
count++;
return "p";
}
};
var base = { p: 2 };

base[prop] += 3;

assert.sameValue(count, 1, "ToPropertyKey(prop) is performed once");
assert.sameValue(base.p, 5, "the result is assigned to the converted key");
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (C) 2026 Sergey Rubanov. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-assignment-operators-runtime-semantics-evaluation
description: >
ToPropertyKey is called only once on the key of base[prop] &= value.
info: |
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression

1. Let leftRef be ? Evaluation of LeftHandSideExpression.
...
3. Let leftValue be ? GetValue(leftRef).
...
9. Perform ? PutValue(leftRef, result).

GetValue ( refRecord )

...
3. If IsPropertyReference(refRecord) is true, then
...
c. If refRecord.[[ReferencedName]] is not a property key, then
i. Set refRecord.[[ReferencedName]] to ? ToPropertyKey(refRecord.[[ReferencedName]]).

PutValue ( refRecord, value )

...
3. If IsPropertyReference(refRecord) is true, then
...
c. If refRecord.[[ReferencedName]] is not a property key, then
i. Set refRecord.[[ReferencedName]] to ? ToPropertyKey(refRecord.[[ReferencedName]]).
---*/

var count = 0;
var prop = {
toString: function() {
count++;
return "p";
}
};
var base = { p: 6 };

base[prop] &= 3;

assert.sameValue(count, 1, "ToPropertyKey(prop) is performed once");
assert.sameValue(base.p, 2, "the result is assigned to the converted key");
Loading
Loading