lgcl-or-assignment-operator-no-set-put-strict.js (792B)
1 'use strict'; 2 // Copyright (c) 2020 Ecma International. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-assignment-operators-runtime-semantics-evaluation 7 description: > 8 Strict Mode - TypeError is thrown if the LeftHandSide of a Logical 9 Assignment operator(||=) is a reference to a data property with the 10 attribute value {[[Set]]:undefined} and PutValue step is reached. 11 flags: [onlyStrict] 12 features: [logical-assignment-operators] 13 14 ---*/ 15 16 var obj = {}; 17 Object.defineProperty(obj, "prop", { 18 get: function() { 19 return 0; 20 }, 21 set: undefined, 22 enumerable: true, 23 configurable: true 24 }); 25 26 assert.throws(TypeError, function() { 27 obj.prop ||= 1; 28 }); 29 assert.sameValue(obj.prop, 0, "obj.prop"); 30 31 reportCompare(0, 0);