Repository navigation
fix(ts): deref a reference to an Arc, a lock, or a pin as the reference - #236
Conversation
…ned Arc Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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: 279719e
One P2 remains in the reference-deref fix: shared Deref of a mutable reference to an Arc still returns its Place wrapper rather than the Arc. See the inline scenario. This is an uncovered case of the existing bug, not a claim of a new regression.
The shared-reference fixtures and exact Pin pointer check otherwise address the extra payload read. Keeping this correction local to Deref is preferable to changing unrelated mappings' reference handling. Extend the differential fixture to mutable-reference inputs and preserve writable aliases separately for DerefMut.
Verification: static lowering, argument/result representation and fixture review, with independent confirmation of the finding. No translator, TypeScript compiler or native/wasm differential tests run; reported reproductions were not independently executed.
(Written by OpenAI)
A `&mut` to an `Arc`, pinned or not, is an `rt.Place`, so `<&mut Arc as Deref>::deref` gives the `Arc` the place holds, while `DerefMut` lends the place on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 4be01fa
The previously reported direct mutable-reference case is fixed: the generated through_arc(&mut ...) and through(&mut pinned) helpers now read p.v.value, while shared-reference helpers retain p.value and DerefMut retains the writable place.
One P2 variant of the same underlying issue remains: Pin<&mut Arc> still returns the Place from shared Deref. This is a pin containing a mutable reference, distinct from the newly tested mutable reference to Pin<Arc>. See the inline scenario and extend the differential fixture to this pointer shape.
Verification: static delta, Pin/reference representation, call argument handling and generated-fixture review, with independent confirmation. No translator, TypeScript compilation or native/wasm differential tests run. No unrelated new regression identified.
(Written by OpenAI)
A pin is its pointer, so `Pin<&mut Arc<T>>`'s shared `Deref` reads the `Arc` out of the `rt.Place` the reference is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 0ec35c2
The remaining P2 in discussion_r4417548147 is fixed: shared Deref of Pin<&mut Arc> now reads the pointer's Place value, while DerefMut preserves the writable place. The new fixture specifically covers Pin::new(&mut owned); its generated accesses are lent2.v.strong and lent2.v.value. The earlier direct mutable-reference fix remains intact.
No new actionable findings in this delta. Reusing the existing pointee conversion keeps the correction local without changing unrelated reference representations.
Verification: static delta, surrounding representation/helper logic and generated-fixture review, with an independent pass. No translator, TypeScript compilation or native/wasm differential tests run; author-reported execution was not independently reproduced.
(Written by OpenAI)
Problem
Derefof a reference to anArc, aMutex, a guard, aRefCellborrow, or aPinmistranslated:Self, so<&Arc<T> as Deref>::derefread theArc's payload instead of giving back theArc;Pin<Arc<T>>arm also stripped references off the pin's pointer, soPin<&Arc<T>>read the payload as well.A local review of #220 found the
Pincase. Reproduced against native wasm32 with new lang fixture cases:Arc::strong_count(&*Pin::new(&arc))and**Pin::new(&arc);Derefthrough a&Pin<Arc<u8>>, a&Arc<u8>, and a&Mutex<u8>, each also through a&mut, andDerefof aPin<&mut Arc<u8>>.On main,
tscrejects these, for examplep.value.valueon au8. Where the payload is itself an object with such a field, the same output would type-check and read the wrong value.Approach
DerefwhoseSelfis a reference to one of these types gives back the object the reference points at: the receiver itself, or for a sharedderefof a&mutthat is anrt.Place(anArc, pinned or not), the place'sv.DerefMutkeeps the place.Pin'sDerefderefs that pointer as it would:.valuefor anArc, compared without stripping references, and a reference as above.I checked the other places #220 added that test for std types (
needs_place, theDerefMutguard incall.rs, andwrite_in): none strips references.library.rs'sDerefmapping forVec,String,Box, andCowmatches the type exactly too.Impact
Alternatives
self_stdfrom stripping references for every mapping intask.rs. Rejected for now: the other arms, such asClone, are never reached through a reference, so onlyDerefneeded it.Follow-ups
None.
Review
Round 1:
quest review, Codex withgpt-6.1-solat medium effort, on head284252fa43813964380c83bb28e69865e8ec784cagainstorigin/mainataed2b009. No findings.An advisory online review of
279719e9then found that a sharedDerefof a&mut Arcstill returned itsrt.Place. Reproduced (tscrejects.valueonPlace<Arc<u8>>forthrough_arc(&mut ..)andthrough(&mut pinned)) and fixed in4be01fa7.Round 2:
quest review --responses, same reviewer and session, on head4be01fa738d15605b001f266f30d60289f1fe679againstorigin/mainataed2b009. No findings.The advisory online review of
4be01fa7found the same bug forPin<&mut Arc<T>>. Reproduced (tscrejects.strongand.valueonPlace<Arc<u8>>) and fixed in0ec35c23.Round 3:
quest review --responses, same reviewer and session, on head0ec35c23027c8a6046c426b563783e184ce1e851againstorigin/mainataed2b009. No findings.Round 4: merged
origin/mainata8e75f2e(ffi only), thenquest review --responses, same reviewer and session, on head705551a741e3e6d724d48c522415070e0feb8fffagainstorigin/mainata8e75f2e. No findings.🤖 Generated with Claude Code
(written by Claude Opus 5.5)