Repository navigation
feat(ts): translate the inherited ne, lt, le, gt, and ge, and byte slice equality - #107
Conversation
Quest-Claim: f04be12ccc3a6bd2
…ice equality A `PartialEq` or `PartialOrd` impl that leaves `ne` or the orderings to its trait, as every derive does, now lowers them as std's defaults: `!eq`, and a test of `partial_cmp` that is false for `None`. `<[u8] as PartialEq>::eq` maps to `rt.byteSliceEq`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
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: 4a1f1fa
No actionable bugs found in the changed code. The direction is sound: recognizing the resolved trait default preserves explicit overrides, reusing call_def avoids duplicating per-type dispatch, and the le/ge spill evaluates partial_cmp once while keeping None false. The byte-slice comparison respects both lengths and offsets. This is simpler than adding per-type comparison mappings or extra runtime ordering helpers.
Verification: inspected the lowering/dispatch paths, pending-expression emission, runtime helper, and Rust/generated-TypeScript fixtures, including unordered and inconsistent equality/ordering cases. I did not run builds or tests; the PR's reported checks were not independently reproduced.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
* chore(quest): claim quest/m2/ts-mir-size.md Quest-Claim: 4f881bb5b70f75e4 * feat(ts): fold single-use temporaries and loop over arrays with for-of Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * feat(ts): share a coroutine field among locals never live at once Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * feat(ts): keep a coroutine's argument in its own field Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * feat(ts): give 64- and 128-bit sums their own functions A bundle with only 64-bit sums, like the async handoff's u64Add, no longer pulls in the 128-bit limbs. sum64 reads halves without boxing a number into limbs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * fix(ts): keep stepped loops as while loops for-of over an array took Firefox 1.19x as long on the async handoff against the stepped loop (A/A 1.05), and Chrome no less time. Without it the handoff is 3440 bytes gzipped, under its 3458 target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * Revert "fix(ts): keep stepped loops as while loops" The Firefox gap was the bench's first translated route, not for-of: timed the other way round, the stepped loops were the slow ones by the same margin, and each A/A copy matched the other build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * chore(quest): narrow ts-mir-size to the codec's gzipped gap Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * chore(quest): restate ts-mir-size's gap after #87 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * test(ts): order a folded read after a write, and two panics Each case fails the lang differential when its rule in inline::folds is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * test(ts): regenerate strs' snapshot for folded temporaries Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * fix(ts): share an upvar's field only with a copy that runs once A capture copied into a local on each pass of a loop shared the capture's field, so changing the copy changed what the next pass copied. The copy must now run at most once, in the first poll, before any other use of the local there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * chore(quest): restate ts-mir-size's codec gap after #82 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * test(ts): regenerate shapes' snapshot after merging main Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn * Regenerate snapshots after merging #107 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn --------- Co-authored-by: Luke Curley <432854+kixelated@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Problem
a != banda < bon a derived type, or on any type whose impl leavesne,lt,le,gt, orgeto the trait's default, were refused as unsupported calls. #98 made comparisons through references reach the referent's impl, which still refused an inherited method.<[u8] as PartialEq>::eqwas also unsupported.Approach
library::Inherited: when a call resolves to the trait's own default body ofPartialEq::neorPartialOrd::lt/le/gt/ge,call_defcallseqorpartial_cmpwith the same generic arguments and operands, then tests the result as std's default does:neis!eq.ltiso === -1andgtiso === 1.leandgeareo !== undefined && o <= 0(or>= 0), with thepartial_cmpspilled to aconstunless it is already a path.partial_cmpreturningNonemakes all four false, whatevereqsays.call_def, soeq/partial_cmpresolve wherever they live: the crate's own or derived impl, std'sOption(rt.cmpOption), or a reference's (referent). An impl that overridesneorltitself is still called directly.<[u8] as PartialEq>::eqmaps to a newrt.byteSliceEq.[T]has noneof its own, so!=on byte slices comes along through the default.Differential tests, in the lang fixture's new
keys::defaults(kind 3 ofkeys):Rough: a hand-writteneqby value and apartial_cmpby quarter that returnsNonepast 200.!=holds alongside<=and>=, and no ordering holds past 200.Skew: its existingpartial_cmpis reversed against its derivedeqand isNonebetween odd values.Option<Rough>, includingSome(a) <= None;Skewed(&Skew), a derive through a reference;Option<Hop>; derivedHorizonandName, through&and&&;Side's derived!=andWay's owneq; and all of it through a genericfn compare<T: PartialOrd>.==and!=, through references and not, at different offsets into one buffer, and empty.Mutation checks against native Rust. Each was caught:
leas!gt(o !== 1)geas!ltneaseqbyteSliceEqignoringstartmoq-net census
At main b09f8aa, with and without this PR's lowering.
ne,lt,le,gt,gene, 53 orderings)eqorpartial_cmppath::Path'sneamong them. The other 54 now report theeqorpartial_cmpthey reach. Most of those are other crates' types:moq_clock::Instant(28partial_cmp),std::time::Duration(9), andVec<Range>(8).(u64, u64) >, 3) andVec'sne(2).Option<(*const (), ...)>::nenow reports itseq.Impact
rt.byteSliceEq(a, b).collections::trait_fnis nowpubwithin the crate. There are no config changes.Choices made without asking (for review)
Option,String, and other crates' types go the same way. For std types it gives what the oldnemapping incollectionsgave, and for the rest it reports the real missing piece (eqorpartial_cmp). Recommendation: keep.leandge, rather than adding??to the printer or a runtime helper. The spill goes throughpre, whichemitorders with pending temporaries, the same wayhasher_callspills. Recommendation: keep.Alternatives
("PartialEq", "ne")and the orderings per type incollections. That would duplicate whateq_fnandcmp_fnreach, and it would miss the crate's own types.rt.partialLe(o)and similar. Inline tests are cheaper and read as the std default does.Follow-ups
<(A, B) as PartialOrd>::lt, 3 in moq-net). std implements them through__chaining_*, not as defaults.Vecs and slices of non-bytes (Vec<Range>, 11 in moq-net).moq_clock::InstantandDurationcomparisons (about 50) follow from supporting those types.Checks:
just check,just test(ts fixtures with differential tests, ffi, uniffi),just ts moq,just ts census, andquest check --base origin/main.(written by Opus 5.5)
🤖 Generated with Claude Code
https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn