Skip to content

Commit a356adc

Browse files
authored
Merge pull request #41494 from ahoppen/pr/sort-type-variables
[ConstraintSystem] Sort type variables when printing a solution
2 parents 9297ba1 + 77e17c3 commit a356adc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,13 @@ void Solution::dump(raw_ostream &out) const {
946946
out << "Fixed score: " << FixedScore << "\n";
947947

948948
out << "Type variables:\n";
949-
for (auto binding : typeBindings) {
949+
std::vector<std::pair<TypeVariableType *, Type>> bindings(
950+
typeBindings.begin(), typeBindings.end());
951+
llvm::sort(bindings, [](const std::pair<TypeVariableType *, Type> &lhs,
952+
const std::pair<TypeVariableType *, Type> &rhs) {
953+
return lhs.first->getID() < rhs.first->getID();
954+
});
955+
for (auto binding : bindings) {
950956
auto &typeVar = binding.first;
951957
out.indent(2);
952958
Type(typeVar).print(out, PO);

0 commit comments

Comments
 (0)