Resolve nested accesses in rewrite constraints (#5872)

A rewrite constraint like `.X = .Y.Z and .Y = .Self and .Z = ()` has a
nested `ImplWitnessAccess` `.Y.Z` (technically `(.Self.Y).Z`). The inner
access `.Self.Y` needs to be resolved (in this case to `.Self`) before
the outer `???.Z` can be resolved as `.Self.Z` which is `()`.
This commit is contained in:
Dana Jansens
2025-07-30 14:34:24 +00:00
committed by GitHub
parent f0cff612eb
commit 105618ecb1
6 changed files with 156 additions and 34 deletions
+1 -4
View File
@@ -635,10 +635,7 @@ static auto GetConstantFacetTypeInfo(EvalContext& eval_context,
// Rewrite constraints are resolved first before replacing them with their
// canonical instruction, so that in a `WhereExpr` we can work with the
// `ImplWitnessAccess` references to `.Self` on the LHS of the constraints
// rather than the value of the associated constant they reference. It also
// ensures that any errors inserted during resolution will be seen by
// GetConstantValueIgnoringPeriodSelf() which will update the phase
// accordingly.
// rather than the value of the associated constant they reference.
info.rewrite_constraints = orig.rewrite_constraints;
if (!ResolveFacetTypeRewriteConstraints(eval_context.context(), loc_id,
info.rewrite_constraints)) {