Repository navigation
chore(quest): plan instance names that adding code elsewhere keeps - #264
Conversation
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 5 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 |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 75ec2cc4b22531607bd08842b770468be0f5f3af.
P2 — Specify collision handling for the hash-based naming option (quest/m2/ts-stable-names.md:41–43). A short hash is not injective: distinct merge keys can produce the same suffix. Falling back to the current $2 numbering would reintroduce the order-dependent renaming this plan promises to eliminate, while omitting disambiguation could emit duplicate identifiers. Replace the unconditional injectivity claim with an explicit collision policy (for example, an injective canonical-key encoding or deterministic diagnostic), and require a forced-collision regression that adds an earlier-sorting instance without silently aliasing or renaming existing symbols. This is a correction to the proposed design, not a new runtime defect in this documentation-only PR.
Direction: naming every mergeable instance from stable intrinsic information, including singleton groups, is the right direction and preserves deduplication. Covering both merge-representative changes and suffix collisions closes the current fixture's main coverage gaps; the proposed bundle-size comparison is appropriate.
Verification limits: GitHub-only static review of the plan, Program::merge/name, and the existing stable_names fixture, with an independent pass. No tests or benchmarks were run; the reported reproduction and local checks were not executed independently.
Problem
moq-dev/rust2#259 found that adding a generic instance in rust2-ts can rename another module's import: a fixture closure renamed
floats.ts'smapOr$Option_Ordering_u8_floats_closure0, so the fixture was changed to avoid it. Unrelated code then changes the output, which churns snapshots and consumers' generated diffs.Reproduced on main at a0f08f4. Adding
out.push(1u8.partial_cmp(&2).map_or(7, |o| o as i8 as u8));to the lang fixture'sfmt::addedfailsstable_namesoncore/option.ts'smapOr$Option_Ordering_u8_floats_closure0.Approach
Adds
quest/m2/ts-stable-names.mdand ranks it first in m2.Program::merge(ts/src/program.rs) keeps whichever identical std instance sorts first bySymbol::key, and that name carries the member closure's identity.Program::namenumbers matching suffixes$2on in key order, which is the same flaw.stable_namesmissed it: its one added root,fmt::added, reaches only a local generic (Wrap::map), which never merges, and no suffix collision.$ncounter with a disambiguator taken from the instance itself. Extendstable_namesto cover both paths.Impact
None: a quest-only change. The planned work renames merged and collided std instances once.
Choices made without asking
$2collision numbering is in scope because it is the same problem (AGENTS.md: fix every instance in one PR).Alternatives
Follow-ups
None.
Review
Skipped for head 75ec2cc: a quest-only change.
quest checkandjust checkpassed locally.(written by Claude Opus 5.5)
🤖 Generated with Claude Code