Skip to content

XS: Proxy ownKeys trap accepts a non-object result #1668

Description

@d01c2

Build environment: macOS 26.5.2

Moddable SDK version:

  • Installed via jsvu, so there is no SDK source tree / git describe.
  • Engine reports: XS 17.9.1, slot 32 bytes, ID 4 bytes

Target device: desktop (host xs)

Description
Object.seal completes successfully when a Proxy's ownKeys trap returns a non-object value.

According to the Proxy [[OwnPropertyKeys]] method, the trap result is passed to CreateListFromArrayLike.

That operation must throw a TypeError if its argument is not an Object. Since 0 is a Number primitive, the call should throw.

Steps to Reproduce

$ xst -e 'Object.seal(new Proxy({}, { ownKeys: () => 0 })); print("completed")'
completed

Expected behavior
A TypeError is thrown.

For comparison, V8 (15.3.27):

$ v8 -e 'try { Object.seal(new Proxy({}, { ownKeys: () => 0 })); } catch (e) { print(e.name); }'
TypeError

Other information
The same issue is directly observable with Reflect.ownKeys, which returns an empty array instead of throwing:

$ xst -e 'print(JSON.stringify(Reflect.ownKeys(new Proxy({}, { ownKeys: () => 0 }))))'
[]

Reflect.ownKeys should also throw a TypeError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    conformancebehavior does not match standard

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions