Skip to content

Commit b201538

Browse files
proggeramlugRalph Küpper
andauthored
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

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v0.5.1214 — setPrototypeOf cycle walk must not advance past chain end (#5866)
2+
3+
Fixes the #5763 regression that broke `Object.setPrototypeOf(obj, proto)` for every acyclic prototype chain of ≥2 links ("Cannot convert undefined or null to object"): the OrdinarySetPrototypeOf Floyd walk advanced the hare past the chain end, and fed exotic `undefined` prototype reports back into the next advance. Every transpiled `__extends` (`setPrototypeOf(Derived, Base)` — a 3-link function proto chain) threw; comment-json's `__extends` + its `{ __proto__: [] }` feature test killed Next.js server boot. The hare now freezes at null (the tortoise completes the membership walk alone, so cycle detection is unchanged) and `undefined` ends the walk like null. e2e regression suite: `crates/perry/tests/issue_5763_setprototypeof_chain_end.rs` (chains of length 2/4, the `__extends` statics link, the feature-test evaluation, and a genuine-cycle negative), byte-for-byte vs `node --experimental-strip-types`.
4+
15
## v0.5.1213 — representation-aware type lowering + native-ABI material evidence gate (#5466)
26

37
Lands the type-lowering track on main (builds on #5291; integrates #5462's

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
88

99
Perry is a native TypeScript compiler written in Rust that compiles TypeScript source code directly to native executables. It uses SWC for TypeScript parsing and LLVM for code generation.
1010

11-
**Current Version:** 0.5.1213
11+
**Current Version:** 0.5.1214
1212

1313

1414
## TypeScript Parity Status

0 commit comments

Comments
 (0)