fix(object): Object.entries/values skip non-enumerable descriptor slots (#5046)#5049
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5046.
Problem
Object.keysconsults the per-property descriptor table and filters keys defined withenumerable: false(theObject.defineProperty(o, k, { value })default), butjs_object_values/js_object_entrieswalked 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_enumerablehelper inobject/field_get_set.rs, applied in bothjs_object_valuesandjs_object_entriesbehind the same cheap any-descriptor probejs_object_keysuses — descriptor-free objects (the overwhelmingly common case) stay on the existing fast path with zero extra string extraction. The_valuetag-dispatch wrappers delegate to these functions, so both entry points are covered.Validation
entries_and_values_skip_non_enumerable_descriptor_slots(keys/values/entries all filtered, pair shape checked); passes.Code-only PR — version bump + changelog left for merge time.