Skip to content

Proxy ownKeys trap accepts a primitive result #1628

Closed

Description

@d01c2

Reproduction

Reflect.ownKeys(new Proxy({}, { ownKeys: () => 0 }));

Expected

A TypeError is thrown.

V8 (15.3.27):

d8> Reflect.ownKeys(new Proxy({}, { ownKeys: () => 0 }));
TypeError: CreateListFromArrayLike called on non-object

Actual (QuickJS-ng)

QuickJS-ng treats the primitive result as an empty key list:

qjs > Reflect.ownKeys(new Proxy({}, { ownKeys: () => 0 }));
[]

Spec

The Proxy [[OwnPropertyKeys]] method passes the result of the ownKeys trap to CreateListFromArrayLike.

CreateListFromArrayLike must throw a TypeError when its argument is not an Object. Since 0 is a Number primitive, the call must throw instead of returning an empty array.

Versions

  • QuickJS-ng: 0.16.0
  • V8: 15.3.27

Activity

  1. added a commit that references this issue on Aug 12, 2026
    82626ea
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