André Bargull c5e18d561c Assignment with left-hand side property accessor
The assignment operator evaluates its operands from left to right. When
the left-hand side expression is a property accessor, RequireObjectCoercible
and ToPropertyKey are called on the property accessor before the right-hand
side expression is evaluated.
2015-05-18 18:12:25 +02:00

26 lines
637 B
JavaScript
Executable File

// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Assignment Operator evaluates its operands from left to right.
description: >
The left-hand side expression is evaluated before the right-hand side.
Left-hand side expression is MemberExpression: base[prop]. ToPropertyKey(prop)
is only called once.
---*/
var propKeyEvaluated = false;
var base = {};
var prop = {
toString: function() {
assert(!propKeyEvaluated);
propKeyEvaluated = true;
return "";
}
};
var expr = function() {
return 0;
};
base[prop] = expr();