lgcl-nullish-assignment-operator-non-writeable-put.js 747 B

1234567891011121314151617181920212223242526
  1. // Copyright (c) 2020 Ecma International. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. esid: sec-assignment-operators-runtime-semantics-evaluation
  5. description: >
  6. Strict Mode - TypeError is thrown if the LeftHandSide of a Logical
  7. Assignment operator(??=) is a reference to a data property with the
  8. attribute value {[[Writable]]:false} and PutValue step is reached.
  9. flags: [onlyStrict]
  10. features: [logical-assignment-operators]
  11. ---*/
  12. var obj = {};
  13. Object.defineProperty(obj, "prop", {
  14. value: undefined,
  15. writable: false,
  16. enumerable: true,
  17. configurable: true
  18. });
  19. assert.throws(TypeError, function() {
  20. obj.prop ??= 1;
  21. });
  22. assert.sameValue(obj.prop, undefined, "obj.prop");