Repository navigation
feat(ts): translate VecDeque::range, str::rsplit_once, and split_terminator - #434
Conversation
Quest-Claim: 11c17c157fc9a81f
…inator Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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 48 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. |
|
codex / Codex land fixer note:
(written by codex / Codex) |
|
codex / Codex land fixer: Conflicts with the base: ts/fixtures/lang/expected/harness.ts (written by codex / Codex) |
Split VecDeque::range's iterator into std's two slices, as #443 splits iter's, and write its Debug in the deque_ranges differential. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # ts/fixtures/lang/expected/harness.ts
Problem
Moving the translator's moq pin past moq's WASM removal added three std calls to moq-net's model that rust2-ts refused:
VecDeque::range(model/group.rs),str::rsplit_onceby achar(model/origin.rs), andstr::split_terminatorby achar(path/mod.rs).Approach
Each maps as its siblings do, with no config:
VecDeque::rangebecomesrt.dequeRange, aDequeIterover the boundsslice::rangechecks, asdrainreads them, so it panics as std's does and clones, reverses, and reports its length asiter's does. It splits the range into the two slices std'sslice_rangesgives, as feat(ts): split a deque's slices where std's are, and translate their Debug #443 splitsiter, so itsDebugandtry_foldmatch std's.str::rsplit_oncebecomesrt.strRsplitOnce, the runtimeSearcher's first match from the back, assplit_onceis its first from the front.str::split_terminatorbecomesrt.strSplitTerminator, the runtime'sSplitwith std'sallow_trailing_emptyunset: it skips an empty last part from either end exactly asSplitInternal::get_endandnext_backdo. Its clone is mapped asSplit's.Both
strcalls take any pattern, assplit_onceandsplitdo.Model census (
ts/moq/model.toml, moq pin4b8e37bd):origin/main)The three refusals named above are the only ones removed, and no refusals were added.
Tests: differential against native wasm32 in the
langfixture:strs::strsreadssplit_terminatorby a char from both ends, andrsplit_onceby a char.strs::slicestakesrsplit_onceby a&str, empty patterns included.collections::deque_rangescovers every form of range over a deque whose front wraps past its buffer's end. It reads from both ends, clones midway, and reverses, and writes the iterator's{:?}after each step, which shows its two slices. A mutant that keeps the range in one slice fails 55 cases.caller.tscover:I mutated each runtime change by hand (the trailing check at the front, the trailing check at the back,
rsplit_oncesearching from the front, andrangeone short). The differential caught each one, with 7, 2, 18, and 174 differences.Impact
rt.dequeRange,rt.strRsplitOnce, andrt.strSplitTerminator. Nothing breaks.Alternatives
VecDeque::range_mutand the rest ofstr's searches here. I left them out to keep this PR to the model's calls; both are recorded as quests (below).Follow-ups
find,strip_prefix,strip_suffix,trim_matches,replace,rsplit,rsplit_terminator,splitn,rsplitn,split_inclusive,matches,rmatches,rmatch_indices,char_indices,lines, andsplit_whitespaceall refused.VecDeque::range_mutof items JS copies is still refused. I added it to The rest of a vector's methods.Review
Codex
gpt-6.1-sol, medium effort, viaquest review --base origin/main, round 1 on head0dd4034bc7b04e6539891459fcc10f60fd17f68d(merged with main through #451,rangesplit as #443'siter): no findings. Heada5c28e15185202d7d24e7ae57407ed14d178342cadds only a conflict-free merge of main (#453).🤖 Generated with Claude Code