1 // Copyright (C) 2021 Alexey Shvayka. All rights reserved.
2 // This code is governed by the license found in the LICENSE file.
5 esid: sec-object.assign
7 [[Set]] to data property of frozen `target` fails with TypeError.
9 SetIntegrityLevel ( O, level )
12 3. Let status be ? O.[[PreventExtensions]]().
15 a. Assert: level is frozen.
16 b. For each element k of keys, do
17 i. Let currentDesc be ? O.[[GetOwnProperty]](k).
18 ii. If currentDesc is not undefined, then
19 1. If IsAccessorDescriptor(currentDesc) is true, then
22 a. Let desc be the PropertyDescriptor { [[Configurable]]: false, [[Writable]]: false }.
23 3. Perform ? DefinePropertyOrThrow(O, k, desc).
26 Object.assign ( target, ...sources )
29 3. For each element nextSource of sources, do
30 a. If nextSource is neither undefined nor null, then
32 iii. For each element nextKey of keys, do
33 1. Let desc be ? from.[[GetOwnProperty]](nextKey).
34 2. If desc is not undefined and desc.[[Enumerable]] is true, then
36 b. Perform ? Set(to, nextKey, propValue, true).
38 OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc )
41 3. If IsDataDescriptor(ownDesc) is true, then
42 a. If ownDesc.[[Writable]] is false, return false.
43 features: [Symbol, Reflect]
47 var target1 = { [sym]: 1 };
49 Object.freeze(target1);
50 assert.throws(TypeError, function() {
51 Object.assign(target1, { [sym]: 1 });
55 var target2 = Object.freeze({ foo: 1 });
57 assert.throws(TypeError, function() {
58 Object.assign(target2, { foo: 1 });