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 non-existing property of non-extensible `target` fails with TypeError.
9 Object.assign ( target, ...sources )
12 3. For each element nextSource of sources, do
13 a. If nextSource is neither undefined nor null, then
15 iii. For each element nextKey of keys, do
16 1. Let desc be ? from.[[GetOwnProperty]](nextKey).
17 2. If desc is not undefined and desc.[[Enumerable]] is true, then
19 b. Perform ? Set(to, nextKey, propValue, true).
21 OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc )
24 3. If IsDataDescriptor(ownDesc) is true, then
26 c. Let existingDescriptor be ? Receiver.[[GetOwnProperty]](P).
27 d. If existingDescriptor is not undefined, then
30 i. Assert: Receiver does not currently have a property P.
31 ii. Return ? CreateDataProperty(Receiver, P, V).
33 ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current )
36 2. If current is undefined, then
37 a. If extensible is false, return false.
41 var target1 = Object.preventExtensions({ foo: 1 });
43 assert.throws(TypeError, function() {
44 Object.assign(target1, { get bar() {} });
50 Object.preventExtensions(target2);
51 assert.throws(TypeError, function() {
52 Object.assign(target2, { [Symbol()]: 1 });