fix(guard): HasPropertyKey ignores keys inherited from Object.prototype - #1699
Open
kevthedawg wants to merge 1 commit into
Open
kevthedawg wants to merge 1 commit into
kevthedawg wants to merge 1 commit into
Conversation
HasPropertyKey used `key in value`, so every plain object "had" toString,
valueOf, hasOwnProperty and the other Object.prototype members. Clean kept
undeclared keys with those names, Check rejected objects that omit an
optional toString or valueOf, Diff missed inserts of those keys, and
{ required: ['toString'] } accepted {}.
HasPropertyKey now walks the prototype chain but stops at Object.prototype,
so class and globalThis instance keys (Date getTime, Uint8Array byteLength)
still count. The emitter keeps the inline `in` for all other keys and calls
the guard for Object.prototype member names. Default and Repair now read
property presence through the guard instead of `value[key]` and `in`.
Fixes sinclairzx81#1698
kevthedawg
force-pushed
the
fix/clean-own-keys
branch
from
September 28, 2026 02:21
fadbbbd to
18b077d
Compare
This branch has not been deployed
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 #1698
HasPropertyKeyuseskey in value, so every plain object picks uptoString,valueOfetc. fromObject.prototype. That's why Clean doesn't remove keys with those names, and it also makesCheckfail when an optionaltoStringis left out, and trips uprequired,Diff,DefaultandRepair.This keeps the prototype walk from 1.0.64 (so
getTimeon aDatestill matches) but stops beforeObject.prototype. The compiled path still inlinesinfor normal keys and only calls the guard forObject.prototypenames, so it's no slower.Added tests for each case.