Skip to content

fix(object): Object.entries/values skip non-enumerable descriptor slots (#5046)#5049

Merged
proggeramlug merged 1 commit into
mainfrom
fix/object-entries-enumerability
Jun 13, 2026
Merged

fix(object): Object.entries/values skip non-enumerable descriptor slots (#5046)#5049
proggeramlug merged 1 commit into
mainfrom
fix/object-entries-enumerability

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Fixes #5046.

Problem

Object.keys consults the per-property descriptor table and filters keys defined with enumerable: false (the Object.defineProperty(o, k, { value }) default), but js_object_values / js_object_entries walked the keys_array unfiltered. Real-world sighting: Object.entries(ansiStyles) over chalk's vendored ansi-styles returned 55 entries under Perry vs Node's 45.

Fix

New shared descriptor_marks_non_enumerable helper in object/field_get_set.rs, applied in both js_object_values and js_object_entries behind the same cheap any-descriptor probe js_object_keys uses — descriptor-free objects (the overwhelmingly common case) stay on the existing fast path with zero extra string extraction. The _value tag-dispatch wrappers delegate to these functions, so both entry points are covered.

Validation

  • New unit test entries_and_values_skip_non_enumerable_descriptor_slots (keys/values/entries all filtered, pair shape checked); passes.
  • End-to-end with the issue repro — Perry now matches Node byte-for-byte:
    [["shown",2]] [2] ["shown"]
    

Code-only PR — version bump + changelog left for merge time.

…ts (#5046)

Object.keys consulted the per-property descriptor table and filtered
keys defined with enumerable: false; js_object_values and
js_object_entries walked the keys_array unfiltered, so
Object.defineProperty(o, k, { value }) slots leaked into entries/values
output (chalk's vendored ansi-styles: 55 entries under Perry vs Node's
45).

Add a shared descriptor_marks_non_enumerable helper and gate it behind
the same cheap any-descriptor probe js_object_keys uses, so
descriptor-free objects stay on the fast path.
@proggeramlug proggeramlug merged commit 550c25a into main Jun 13, 2026
13 checks passed
@proggeramlug proggeramlug deleted the fix/object-entries-enumerability branch June 13, 2026 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Object.entries/values include non-enumerable defineProperty slots (Object.keys is correct)

1 participant