fix(runtime): reify all Reflect namespace members as real values - #7005
Conversation
7c986e5 to
d34d850
Compare
|
Warning Review limit reached
Next review available in: 33 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughReflect namespace members now resolve to concrete runtime thunks for reflection operations. The thunks delegate to proxy helpers, and the namespace installation imports and assigns those bindings instead of using noop stubs. ChangesReflect runtime values
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
d34d850 to
799eef1
Compare
799eef1 to
36c8e86
Compare
Any code that stores a
Reflectmethod in a variable and calls it later getsundefinedback instead of a result — forReflect.ownKeysthat means destructuring or iterating the "key list" throws at module init.Background on the mechanism: bundler-emitted "primordials" captures are a common hardening pattern —
const ReflectOwnKeys = Reflect.ownKeys;at load time, calls through the stored binding forever after. The runtime installs theReflectnamespace's members for reflection parity (#4139), but most members were installed as noop stubs that exist as properties without being callable as values: calling one silently returnsundefined.Reflect.applyandReflect.constructhad already been reified as real values for exactly this reason (#5989 — a captured-binding call from a Date extension); the other eleven members still had the stub behavior.Minimal repro
Observed in the wild through a hardened-primordials library whose
recursiveFreezewalkedReflect.ownKeys(obj)at class-static-init time.Root cause
crates/perry-runtime/src/object/global_this/install_static.rs:860—install_reflect_namespace_membersinstalledget,set,has,deleteProperty,defineProperty,getOwnPropertyDescriptor,getPrototypeOf,setPrototypeOf,isExtensible,ownKeys, andpreventExtensionswithglobal_this_builtin_noop_thunk, so a call through a stored binding returnedundefinedwith no error.The fix adds one thunk per remaining member in
bigint_promise.rs(same shape as the existingreflect_apply_thunk/reflect_construct_thunk), each routing to its already-implementedcrate::proxy::js_reflect_*runtime function, and wires them into the member table. No new runtime behavior — the implementations existed; only the namespace's value-position dispatch was missing.Test plan
Found while compiling a manifest generation CLI — a real-world TypeScript CLI with a deep pnpm dependency graph. Independent of the other fixes from that effort; lands standalone.
Summary by CodeRabbit
Reflectmethods so they now perform their intended runtime operations when stored or reused as standalone values.