[ConstraintSystem] Add a missing case to locator simplification

If tuple element is anchored on an assignment, we need to look
at the source of the assignment to find tuple expression the
element belongs to.
This commit is contained in:
Pavel Yaskevich
2023-10-13 10:39:38 -07:00
parent fad02e3737
commit 557c6f71f2

View File

@@ -5729,6 +5729,13 @@ void constraints::simplifyLocator(ASTNode &anchor,
// Extract tuple element.
auto elt = path[0].castTo<LocatorPathElt::AnyTupleElement>();
unsigned index = elt.getIndex();
if (auto *AE = getAsExpr<AssignExpr>(anchor)) {
if (isa<TupleExpr>(AE->getSrc())) {
anchor = AE->getSrc();
}
}
if (auto tupleExpr = getAsExpr<TupleExpr>(anchor)) {
if (index < tupleExpr->getNumElements()) {
anchor = tupleExpr->getElement(index);
@@ -5744,6 +5751,7 @@ void constraints::simplifyLocator(ASTNode &anchor,
continue;
}
}
break;
}