Repository navigation
fix(sort): insertion_sort unsigned-index underflow; reseal 9 stale sort/wp18 seals - #6618
Merged
Merged
Conversation
…rt/wp18 seals insertion_sort tracked j = i - 1 and looped while j >= 0, which on the generated usize index is always true and underflows when a key reaches slot 0. Track the free slot instead (j = i, stop at j > 0). Replace the placeholder sort_basic_case, which could not compile, with a real test. Both tests pass (t27c test-report 2/2). Seals regenerated on the Railway t27c lab with master's compiler via tri seals drift --fix. Refs #6609 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 5, 2026
Contributor
This was referenced Oct 5, 2026
Merged
Closes #6609 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
PR DashboardGenerated at: 2026-10-05 21:50:53 UTC
Summary
Seal Status
|
Closes #6609 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
PR DashboardGenerated at: 2026-10-05 21:57:40 UTC
Summary
Seal Status
|
Closes #6609 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
PR DashboardGenerated at: 2026-10-05 22:06:26 UTC
Summary
Seal Status
|
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.
Closes #6609 (this is the coverage half; the GateScarab corpus-ratchet half landed in #6612, merged into this branch)
What was wrong in insertion_sort
The body was wrong. The test expectation was right.
var j = i - 1; while (j >= 0 && values[j] > key)lowers to an unsignedusizeindex in the generated Zig. That makesj >= 0always true, andj = j - 1underflows as soon as a key has to move to slot 0. The body now tracks the free slot (var j = i; while (j > 0 && values[j - 1] > key)), the standard unsigned-safe form.sort_simple_case({5,2,8,1,9}->{1,2,5,8,9}) is what a correct insertion sort produces and is unchanged.sort_basic_casewas a given/when/then placeholder (sort(undefined), compared to a void result) that could not compile. It is now a real test with duplicates, a negative minimum that must move to slot 0, and an already-sorted tail.Verification (Railway t27c lab, master 13e212a compiler)
t27c test-report specs/tri/sort/insertion_sort.t27: 2/2 pass (was 0/2)tri seals drift --fixresealed TriCountingSort, TriHeapSort, TriInsertionSort, TriTimSort, theirsort_*twins, and tools_Wp18GateSelfConsistentSelfTestpython3 tools/check_seal_coverage.py:OK: 1454 seals, 1310 hold, 144 known-broken(baseline unchanged, nothing baselined)Files: one
.t27, 9 generated seals, one docs/now entry. No foreign code.🤖 Generated with Claude Code