Skip to content

dedupe the dispatch gates; add sort_by_key to std.algo#274

Merged
kacy merged 1 commit into
mainfrom
sprint-finish
Jul 8, 2026
Merged

dedupe the dispatch gates; add sort_by_key to std.algo#274
kacy merged 1 commit into
mainfrom
sprint-finish

Conversation

@kacy

@kacy kacy commented Jul 7, 2026

Copy link
Copy Markdown
Owner

summary

the sprint's last two items:

  1. dispatch-gate dedup — the checker repeated its method-table gate condition six times; the one wrong copy of it caused the set.insert compiler crash. now one predicate, method_table_answered, with the contract (and its kept wart: TID_ERR answers still fall through) stated in comments.
  2. std.algo.sort_by_key / sort_by_key_desc — stable, string-keyed struct sorts with a key closure. sitegen's date sort and parq's name sort drop their hand-rolled insertion loops; both golden checks byte-identical.

the bug it found

ordered string comparison inside generic bodies still pointer-compares — the #258 fix dispatches on checked operand types, and generic bodies check with type params suppressed, so the first sort_by_key silently misordered. it compares through strcmp (concrete code) instead; the emitter-side fix direction is filed.

what was tested

new regression covers ascending/descending/stable-ties/empty; full suite green including all four golden checks; fixed point byte-identical; seed refreshed; fmt gate clean on all touched files.

the elegance sprint's last two items, in one change.

the checker's method dispatch repeated its gate condition six times —
the exact condition whose one wrong copy let set.insert fall through
to the map table and take down the compiler. the predicate now has
one home, method_table_answered, and the comments state the contract
plainly, including the long-standing wart it keeps: a table that
reports an error and returns TID_ERR still falls through to the
user-defined lookup.

std.algo gains sort_by_key and sort_by_key_desc: stable, string-keyed
struct sorts taking a key closure. sitegen's date sort and parq's
name sort drop their hand-rolled insertion loops for them, with both
golden checks proving output unchanged byte for byte.

writing the new function found a bug: ordered string comparison
inside generic bodies still compares pointers — the earlier fix
dispatches on checked operand types, and generic bodies check with
type parameters suppressed. sort_by_key compares through strcmp,
whose comparison runs inside concrete code, and the emitter-side fix
is noted where the earlier one lives.
@kacy kacy merged commit 7f8418f into main Jul 8, 2026
2 checks passed
@kacy kacy deleted the sprint-finish branch July 8, 2026 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant