Files
carbon-lang/toolchain/check
Dana JansensandJon Ross-Perkins 09a5fddff8 Fix sorting of instructions in Facet Type resolution (#5664)
The sort and dedupe operations in facet type resolution explicitly work
with `ImplWitnessAccess` instructions as being a reference to an
associated constant on some entity. If only one of the instructions is
an `ImplWitnessAccess`, we still want to consider that one as such, not
get its constant value, which may be some concrete type, and use that
for comparison instead.

This makes the new test fail (which we don't want) in a consistent way
with a similar test of TypeAnd (which we also don't want to fail),
making the system more consistent, while leaving some improvements to be
done.

Avoid inconsistent orderings between instructions, by making the
comparison function into a total order. To do so, we sort
ImplWitnessAccess instructions first, and sort them by their InstId.
Non-ImplWitnessAccess instructions come second, and sort them by their
constant InstId. Thanks to jonmeow for figuring out that the function
was not producing a total order and why.

Since this means the order is no longer relative to source order, we
order the two assignments in the diagnostic by source order(ish) by
putting the lower InstId first in the diagnostic output.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
2025-06-13 18:01:39 +00:00
..
2025-04-11 21:47:43 +00:00
2025-06-12 20:37:27 +00:00
2025-06-12 22:06:12 +00:00
2025-04-14 14:28:15 +00:00
2025-06-12 22:06:12 +00:00
2025-04-14 14:28:15 +00:00
2025-04-14 14:28:15 +00:00
2025-03-01 08:00:17 +00:00