Skip to content

Proxy ownKeys trap accepts a primitive result #1628

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

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