Repository navigation
feat(ts): replace a captured &mut's object, and default a crate type in place - #204
Conversation
Quest-Claim: dc5440d35e7dcb4b
…in place Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…finish the places quest Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 4092a75bee21c7f3018ce2a2dd6d67a76f78a8cf.
No actionable bugs found. Materializing the option target before branching fixes the lifetime of the generated temporary, and reusing default_of preserves lazy construction while admitting crate-defined defaults. Widening captures only for established borrowed-place aliases is a focused alternative to mutating every JS container in place; existing alias-stability checks remain in force. The generated examples write replacements back to the caller or coroutine state, including disjoint tuple fields, while unsupported whole-object parameter replacement remains refused.
Verification: static review of capture/place/store lowering, default insertion, and the generated synchronous and async/cancellation fixtures, with an independent alias-path check. No builds, differential tests, census, or reported mutation check were run; reported results were not independently reproduced.
(Written by OpenAI)
Co-authored-by: Luke Curley <432854+kixelated@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Problem
The model's census still refused two writes through places (quest, found by #168):
origin.rs:4052:listing.get_or_insert_default()on anOption<FrontListing>, a crate type.get_or_insert_defaultonly knew std types' defaults.origin.rs:3212:mem::take(&mut in_flight)inside akio::waitclosure that captured theVecby&mut. Only a capture of a type JS copies read the borrowed place; a capture of an object held the object, so nothing could replace it whole.The
group.rsrefusals the quest listed were already cleared by #193.Approach
get_or_insert_defaultmakes its value withdefault_of, which calls the crate'sDefaultimpl when the type isn't std's.option_inserttested a place whose held-back definition a call in thethenbranch could flush into that branch, so the other path read it unset (TypeErroron.v). It now materializes what the test reads before branching.&mutalias of a borrowed place as that place, not only one to a value JS copies, so a write of the whole value lands on the caller's variable or field. Passed on whole, the capture is still anrt.Placeonly for a value JS copies.mem::take/replacethrough an alias accept a member of an element (pair[1].listed) as an assignable target, which a disjoint field capture yields. Before, this was refused even without a closure.Tests (differential against native wasm32, each reading the write after):
refs:get_or_insert_default/get_or_insert_with(Listing::default)of a crate type, through a local, a&mut, and a closure, then reset;mem::take/replaceof capturedVec<u8>andVec<u32>, from a nested closure, of a&mutmoved into amoveclosure, of disjoint tuple fields, and of a field of what a&mutparameter points at.front: moq's shape. A listing defaulted in place between awaits, and an in-flightVecheld in coroutine state that akio::waitclosure takes and refills each poll, read after the await, and cancelled mid-wait.With the
materializefix reverted, lang fails with 521 differences.Census (
just ts census):The cleared refusals are
origin.rs:4052(get_or_insert_default),origin.rs:3212(mem::takeof the capturedVec), andietf/subscriber.rs:6437(mem::take(&mut self.properties)in a closure). No refusal was added.Impact
&mutto an object now read and write the borrowed place. No existing fixture's output changed.Alternatives
splice) behind any reference. That would also cover a&mut Vecparameter replaced whole, but it changes what an alias of the old value sees and needs per-kind runtime helpers. A capture of a borrowed place needs neither.Follow-ups
&mutparameter to an object (mem::take(v)withv: &mut Vec<_>, with or without a closure) is still refused: 9 in moq-net, 4 in the model. It's a separate gap from captures.Vec::retainthrough a place is refused (found while writing the fixture).🤖 Generated with Claude Code