target-member-computed-reference.js (1104B)
1 // Copyright (C) 2015 André Bargull. All rights reserved. 2 // Copyright (C) 2024 Sony Interactive Entertainment Inc. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-assignment-operators 7 description: Assignment Operator evaluates its operands from left to right (formerly S11.13.1_A7_T3) 8 info: | 9 The left-hand side expression is evaluated before the right-hand side. 10 Left-hand side expression is MemberExpression: base[prop]. 11 ToPropertyKey(prop) occurs after both sides are evaluated. 12 ---*/ 13 14 function DummyError() { } 15 16 assert.throws(DummyError, function() { 17 var base = {}; 18 var prop = function() { 19 throw new DummyError(); 20 }; 21 var expr = function() { 22 throw new Test262Error("right-hand side expression evaluated"); 23 }; 24 25 base[prop()] = expr(); 26 }); 27 28 assert.throws(DummyError, function() { 29 var base = {}; 30 var prop = { 31 toString: function() { 32 throw new Test262Error("property key evaluated"); 33 } 34 }; 35 var expr = function() { 36 throw new DummyError(); 37 }; 38 39 base[prop] = expr(); 40 }); 41 42 reportCompare(0, 0);