Commit b201538
fix(runtime): setPrototypeOf cycle walk must not advance past chain end (#5866)
* fix(runtime): __proto__ cycle walk must treat undefined getPrototypeOf as chain-end
js_object_get_prototype_of returns undefined (not spec's object-or-null)
for some exotic receivers; the OrdinarySetPrototypeOf cycle walk fed that
back into the next advance and threw "Cannot convert undefined or null to
object". comment-json's __extends feature-test ({__proto__: []}) hit this
at Next.js server boot. Undefined can never be part of a genuine cycle,
so it ends the walk like null.
Claude-Session: https://claude.ai/code/session_01RcePwqv92QidGakrfYvf3v
* fix(runtime): setPrototypeOf cycle walk must not advance the hare past chain end
The Floyd walk in js_object_set_prototype_of only null-guarded the hare's
second step. On any acyclic proto chain longer than one link (every
function/class proto: fn -> Function.prototype -> Object.prototype -> null)
the hare reaches null first and the next iteration called advance(null) ->
js_object_get_prototype_of(null) -> TypeError 'Cannot convert undefined or
null to object'. comment-json's __extends hit this on every transpiled
subclass, killing Next.js server boot on main (bisected to 1f4a2c5,
#5763). Freeze the hare at null; the tortoise still completes the
obj-membership walk, and a cyclic chain never yields a null hare.
Claude-Session: https://claude.ai/code/session_01RcePwqv92QidGakrfYvf3v
* test(runtime): #5763 regression — e2e guards for setPrototypeOf chain-end fixes
Four cases vs node --experimental-strip-types: acyclic chains of length
2/4, the __extends statics link (3-link function proto chain), the
comment-json {__proto__: []} feature-test evaluation (throw-only guard;
the instanceof gap is separate and pre-existing), and a genuine-cycle
negative.
* chore(release): v0.5.1214 — version bump + changelog for #5866
---------
Co-authored-by: Ralph Küpper <ralph@skelpo.com>1 parent e8e2b52 commit b201538
6 files changed
Lines changed: 285 additions & 80 deletions
File tree
- crates
- perry-runtime/src/object/object_ops
- perry/tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
1 | 5 | | |
2 | 6 | | |
3 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
0 commit comments