Reproduction
Reflect.set({}, "x", 1, null);
Expected
false is returned.
V8 (15.6.20):
d8> Reflect.set({}, "x", 1, null);
false
Actual (QuickJS-ng)
QuickJS-ng throws instead of returning a Boolean:
qjs > Reflect.set({}, "x", 1, null);
TypeError: cannot set property 'x' of null
Spec
Reflect.set forwards to the target's [[Set]] with the given receiver. For a data property, OrdinarySetWithOwnDescriptor reaches the step "If receiver is not an Object, return false", so an assignment through a receiver that cannot hold properties is reported as a failed assignment rather than an error.
Only null and undefined are affected: Reflect.set({}, "x", 1, 5) returns false in QuickJS-ng. The target does not matter, since a typed array throws in the same way.
Versions
- QuickJS-ng: 0.17.0
- V8: 15.6.20
Reproduction
Expected
falseis returned.V8 (15.6.20):
Actual (QuickJS-ng)
QuickJS-ng throws instead of returning a Boolean:
Spec
Reflect.setforwards to the target's[[Set]]with the given receiver. For a data property,OrdinarySetWithOwnDescriptorreaches the step "Ifreceiveris not an Object, returnfalse", so an assignment through a receiver that cannot hold properties is reported as a failed assignment rather than an error.Only
nullandundefinedare affected:Reflect.set({}, "x", 1, 5)returnsfalsein QuickJS-ng. The target does not matter, since a typed array throws in the same way.Versions