Skip to content

Reflect.set throws when the receiver is null or undefined #1730

Description

@d01c2

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions