Repository navigation
feat(ts): call a crate's own lt, le, gt, and ge where std does - #173
Conversation
Quest-Claim: 2db6de1a078aecfd
Sorts, Ord's max, min, and clamp, and a tuple's, Arc's, or Reverse's comparisons now call the crate's own PartialOrd test where std's do, rather than refusing it. 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: 547a233
No actionable bugs found in the changed lowering, runtime helpers, or differential fixtures. Routing default and overridden comparisons through the same boolean-test interface is a sensible simplification; tuple prefixes retain partial_cmp semantics while the final field, Arc, and Reverse dispatch the appropriate override. The migration note covers the runtime API changes, and the new fixtures exercise all four overrides, nested wrappers, sorting, and clamp's bounds check.
Verification: GitHub source/diff review only; I did not run the translator, TypeScript checks, or differential tests.
# Conflicts: # ts/fixtures/lang/expected/harness.ts # ts/fixtures/lang/src/harness.rs
|
Merging: CI passed and Codex reviewed head Suggested follow-up from the PR body: (Written by Claude Opus 5.5) |
Finishes quest/m3/ts-partial-ord.md.
Problem
#124 refused any comparison that reaches a crate's own
PartialOrd::lt,le,gt, orgethrough std: sorts,Ord::max/min/clamp, and a tuple's,Arc's, orReverse's<. std calls the override there; the translation only hadpartial_cmp.Approach
collections::test_fnbuilds<T as PartialOrd>::{test}as a JS function: the crate's own whereTreaches it (directly, as a tuple's last field, throughArc, throughReverseswapped), elsert.cmpLt/cmpLe/cmpGt/cmpGeoverpartial_cmp, as the trait's defaults test.partial_cmp, as std's__chaining_*do (rt.testTuple); anOptionand a slice still compare bypartial_cmp, as std's do.ordMax/ordMin/ordClampand sorts take those tests rather than apartial_cmp, so one path serves std's types and the crate's.sort/sort_unstablecall the newrt.sliceSort(the existing merge sort, exported);cmpArcandcmpReversewiden to tests.Lopsided) are gone.Differential test: a new
keys::overrideslang case with a type whoselt,le,gt,geeach disagree with itspartial_cmp, covering direct, tuple (with nested-tuple prefix),Arc,Reverse,Option,max/min/clamp(incl. themin <= maxpanic),sort,sort_unstable_by_key, and tuple sorts. Forcingtest_fnback topartial_cmpmakes it fail with 424 differences over 485k cases.Impact
rt.cmpLt(cmp)where they passedcmp.ts/MIGRATE.md):rt.ordMax,rt.ordMin,rt.sliceSortByKeytake anlt;rt.ordClamptakesle,lt,gt;rt.sliceSortBytakes anOrderingcomparator only. New:rt.sliceSort,rt.testTuple,rt.cmpLt/cmpLe/cmpGt/cmpGe.Consumer: moq, whose types derive
PartialOrdtoday; this removes a refusal any stock crate with a hand-writtenlthits.Choices made without asking
cmptort.cmpLt(cmp), with no extra calls per comparison.<branch keeps its inlinepartial_cmptest when nothing overrides, for tighter output.Alternatives
Follow-ups
std::cmp::max/min(the free functions) are unsupported calls; found writing the test.rt/collections.ts.🤖 Generated with Claude Code
(Written by Claude Opus 5.5)