dedupe the dispatch gates; add sort_by_key to std.algo#274
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
the sprint's last two items:
method_table_answered, with the contract (and its kept wart: TID_ERR answers still fall through) stated in comments.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.