fix: specializations and deduction guides are listed in order - #1264
Open
gennaroprota wants to merge 1 commit into
Open
fix: specializations and deduction guides are listed in order#1264gennaroprota wants to merge 1 commit into
gennaroprota wants to merge 1 commit into
Conversation
✨ Highlights
🧾 Changes by Scope
🔝 Top Files
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1264 +/- ##
========================================
Coverage 83.12% 83.12%
========================================
Files 35 35
Lines 3662 3662
Branches 844 844
========================================
Hits 3044 3044
Misses 410 410
Partials 208 208
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
An automated preview of the documentation is available at https://1264.mrdocs.prtest2.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-08-26 10:06:37 UTC |
In both lists, all elements take the name of the primary, so comparing names never decided anything, and the order fell through to the symbol IDs, which are hashes of the declaration. They now compare on what is there in them beyond that shared name: what a specialization was specialized with, and what a guide deduces, with the types a guide takes deciding between guides that deduce the same thing. Fixes cppalliance#1250. Fixes cppalliance#1260.
gennaroprota
force-pushed
the
fix/sort_specializations_and_deduction_guides
branch
from
August 26, 2026 09:57
e890679 to
be3f6d7
Compare
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.
SpecializationFinalizer::sortBackPointerscomparedSymbol::Nameand fell back to comparing theSymbolIDs. But every entry in the lists of specializations and deduction guides carries the name of the primary, so the name never decided anything and the order was always the fallback (the order of the hashes). That is the "weird" order both #1250 and #1260 report, and it is one root cause behind both of them, since specializations and deduction guides go through the same comparator.These lists now go through
SymbolIDCompareFn, the comparison every other list of symbols uses, which already ranked template arguments. Only the guides needed anything new:GuideSymbol::operator<=>never comparedDeduced, although its documentation said it did, so guides that deduce different specializations were ordered by the types they take instead. What a guide deduces decides first now, with the types it takes deciding between guides that deduce the same thing.The new fixture declares everything out of order on purpose. Its specializations come out as:
and its deduction guides as:
(Note the two guides that deduce
B<int>.)Types rank by kind, in the order the type nodes are declared: a named type, then a reference, then a pointer. That is why
A<int, int>comes first andA<T*, U>last. It is the same ranking the existing comparison already applied to template arguments elsewhere.Fixes #1250.
Fixes #1260.
Changes
SymbolIDCompareFn, the comparison used for every other list of symbols, which moves to a header of its own so both finalizers share it.GuideSymbol::operator<=>gained theDeducedcomparison its documentation already promised. The doc comments on the affected fields ofRecordSymbolandFunctionSymbolare corrected too, as they referred to sorting by referent name then ID.Testing
The new fixture pins both lists and the tie-break between guides that deduce the same specialization, in a generator whose output shows names rather than hashes.
Documentation
No change is needed under docs/.