Repository navigation
feat(ts): translate Arc's get_mut, make_mut, and pin, and as_deref of an Option<Arc> - #238
Conversation
Quest-Claim: 4bf81eb5cc775de9
… an Option<Arc> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…&mut as std's mappings take it 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 3473265.
One P2: function-value argument unwrapping now mistakes a generic by-value parameter instantiated as &mut T for a declared mutable-reference parameter. Pin::new used as a function pointer consequently returns a copied value instead of its Place; see the inline example.
Direction: centralized signature normalization and the Arc/Rc runtime operations are coherent. The custom-Clone last-owner drop correction and get_mut function-value receiver correction are reflected in code and fixtures. Preserve the direct-call distinction between declared references and generic values when applying the latter fix. The separately reported Option::cloned limitation is unchanged, not a new finding here.
Limits: GitHub-only static review of changed code, runtime/lowering surroundings and differential fixtures/generated snapshots. No compiler, TypeScript, wasm differential tests or census executed; reported passing checks were not independently reproduced.
(Written by OpenAI)
…eclares one Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # ts/fixtures/lang/expected/harness.ts
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit 67959e0 against my prior review at 3473265, separating inherited main changes.
Fixed: the function-value generic mutable-reference P2. The shared pointer::pointees helper checks declared parameters rather than instantiated generic values, so Pin::new preserves its Place while Arc::get_mut still receives its pointee. The new function-pointer fixture mutates through the returned pin and reads the original byte; its generated snapshot returns a0, not a0.v.
No new actionable bugs found in this delta. Direction: sharing the existing direct-call rule is simpler and less likely to drift than maintaining a separate function-value heuristic. The make_mut Place exception remains intact.
Verification: GitHub-only static inspection of lowering, helper extraction, relevant generated snapshots and regression coverage, with an independent review pass. No compiler, TypeScript, wasm differential tests or census executed; reported passing checks were not independently reproduced.
# Conflicts: # quest/m3/ts-arc-mut.md
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
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 |
Problem
Arc::get_mut,Arc::make_mut,Arc::pin, andOption::as_derefof anOption<Arc>were refused, forRctoo (quest/m3/ts-arc-mut.md).as_dereffailed for a broader reason: the translator took a callee's signature unnormalized in 15 places. So a function item such as<Arc<u8> as Deref>::derefpassed as a value kept<Arc<u8> as Deref>::Targetas an unresolved projection.Approach
get_mut:rt.arcGetMutgives the value whilestrong === 1 && weak === 0, as std'sis_uniquedoes. A value JS copies gets anrt.Placeover theArc'svalueinstead (arcGetMutPlace), followinglocalKeyWithBorrowMut's split.make_mut: this takes theArc'srt.Place(added totakes_place), withT'sCloneand theArc's dropper.Arcshares the value, it clones the value into a newArcat the place and drops the oldArc. If the clone released the other owners, that drop is the last one and drops the value.Weaks share it, it moves the value to a newArcand leaves theWeaks dangling (strong count 0).Tis refused.Arc::pin: this isnew rt.Arc, since JS erases the pin.Translator::sig: a new helper gives a callee's signature with its projections normalized. All 15fn_sig(..).instantiate(..).skip_norm_wip()sites use it, includingty()for a function item. This replaces three hand-rolled normalizations.Body::fn_value: this now passes a&mutparameter that std declares, and that is anrt.Place, as what it points at, as call sites' operands do (both usepointer::pointees). So a mapped std function used as a function pointer, such asArc::get_mut, gets theArc.std_places: the list of mappings that hand back a place for a value JS copies now includesArc/Rcget_mutandmake_mut.counts.rs(newunique_arcs/unique_rcs, plus new ops inarcs/rcs). They cover:get_mutandmake_muton a byte and on aDropvalue with a customClone, called directly and through function pointers;make_mutleaves, including danglingWeaks;Clonereleases the other handles;Arc::pin, andas_derefof anOption<Arc>.Census on moq (
just ts census, main5318470avs this branch):No new refusal kinds. Most of the drop is unresolved projections ("unsupported type", 46 → 26 in moq-net), which
Translator::sigfixes.Impact
arcGetMut,arcGetMutPlace,arcMakeMut, andarcMakeMutPlace, which only generated code calls. No public API change.Alternatives
get_mutto an inlinestrong === 1 && weak === 0 ? … : undefined. Rejected because it evaluates the receiver twice, and the TS AST has no optional chaining.FnDefarm andfn_value. Rejected: the other 13 sites share the bug, and three already normalized it in their own ways.Follow-ups
Option::clonedignoresClone. It lowers throughcopied, soopt_ref_arc.cloned()takes no count (it later drops one too many), and a customCloneimpl never runs. Found while writing this fixture (it used.map(Arc::clone)instead). It's a silent miscompile on main, so I suggest a quest via/quest-plan.Review
Round 3:
quest review --responses, Codex withgpt-6.1-solat medium effort, on head67959e0502634e7ae5d73ccf613b6694bd67147eagainstorigin/mainatf78c588f. No findings.Since round 2:
34732656(thread): function-value wrappers tested the instantiated signature, soPin::newthrough a function pointer returneda0.v. Fixed in015ec2e4.tscrejected theu8returned as aPlace<u8>.pointer::pointeesnow decides from std's declared signature, for call sites andBody::fn_valuealike, andfn_valuestill checks the concrete place.pin_viacovers it.origin/main: the generatedharness.tssnapshot conflicted, so I regenerated it.Round 2, on
34732656, had no findings. Round 1, on0c480dc2, had two findings, both fixed and reproduced first:make_mutdecremented the replacedArcwithout dropping it. Fixed: it now drops through theArc's dropper.Arc::get_mutas a function value received the place, not theArc. Fixed inBody::fn_value.just checkandjust testpass on the reviewed head.Merge of main at
af6f0246f71cfe144758dac9157d36b6a6490458: the only conflict was this PR deleting its finished quest file while #249 updated that file's links; resolved by deleting it. Nothing else changed since the reviewed head67959e05, so this merge is a recorded skip, too trivial to review.🤖 Generated with Claude Code
(written by Claude Opus 5.5)