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