JavaScript: legacy reflect find skips proxy traps; replacer lists charge kept names

- `reflect.find` reads the reflection object and its lists with ordinary
  [[GetOwnProperty]], so a proxy receiver throws a TypeError without its
  getOwnPropertyDescriptor trap running.
- `JSON.stringify` charges each distinct name a replacer array keeps for
  the length of the call, instead of reserving bytes for the whole length,
  so a long sparse replacer list no longer hits the heap limit.
- A test checks that an outer proxy reads an inner proxy target's
  descriptors in its trap's combined order of names and Symbols.
This commit is contained in:
dotCooCoo committed 2026-12-02 06:01:07 -08:00
1 parent f2d79f2460
commit 080f3c4a84
4 files changed
+85 -14

No files matched your search

+4 -2
View File
@@ -2902,7 +2902,8 @@ A conversion or syntax error throws before that prototype getter runs.
membership checks use host collection indexers, including numeric indices and named items.
`JSON.stringify` uses `ToLength` for proxy array lengths and proxy replacer-array lengths, so negative lengths
become zero and fractional lengths are truncated. It checks run limits before allocating array traversal keys
or iterating either list. Array traversal keys count against the heap limit until their writing frame is dropped.
or iterating either list. Array traversal keys count against the heap limit until their writing frame is dropped,
and each distinct name a replacer array keeps counts against it until the call returns.
Its `toJSON` lookup skips host collection indexers through empty-handler proxies
and calls an explicit `get` trap when present.
`concat` and `JSON.parse` reviver traversal also use `ToLength` for proxy arrays. They check lengths before
@@ -2911,7 +2912,8 @@ the maximum safe integer. Reviver traversal keys count against the heap limit un
In E4X mode, a bare call resolves each scope once. An object binding still checks property membership again
when reading its value; a binding removed between those checks does not select an outer function.
The legacy `Object.prototype.reflect` getter throws `TypeError` for a proxy receiver without enumerating
its properties or calling descriptor traps. Symbol property reads, writes, deletion, descriptor operations
its properties or calling descriptor traps. Its `find` method reads a receiver's own properties without
calling proxy traps, so a proxy receiver throws `TypeError`. Symbol property reads, writes, deletion, descriptor operations
and symbol enumeration on a revoked proxy also throw `TypeError`.
A Symbol key on a proxy goes through the same traps as a string key (`get`, `set`, `has`, `deleteProperty`,
`defineProperty` and `getOwnPropertyDescriptor`), which receive the Symbol itself; without a trap the operation