Skip to content

Object rest drops Symbol-keyed own properties #10815

Description

@proggeramlug

const {...rest} = obj silently drops Symbol-keyed own properties from rest instead of copying them through.

const s = Symbol("k");
const obj = { a: 1, [s]: 2 };
const { ...rest } = obj;
console.log(Object.getOwnPropertySymbols(rest).length);  // node: 1, perry: 0
console.log(rest[s]);                                     // node: 2, perry: undefined

Per spec, object rest performs CopyDataProperties, which iterates OwnPropertyKeys — that includes Symbol keys, and excludes only the pattern's named keys and non-enumerable properties. Symbol-keyed own enumerable properties must be copied.

Reproduces on an unmodified base binary, so it predates and is unrelated to #10814 (which only changes how the excluded-key array is built in codegen). The behaviour lives in js_object_rest's key-copy logic, crates/perry-runtime/src/object/delete_rest.rs.

Found while writing the gap test for #10814. That test deliberately scopes this case out with an explanatory comment rather than asserting the wrong output, so the coverage gap is visible in the source rather than silently baked in — worth removing that scope-out as the fix's regression test.

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