Skip to content

Commit 086ad33

Browse files
[CSDiagnostics] Adjust tuple contextual mismatch diagnostics to handle Subscript assign to source
1 parent ab0e8a8 commit 086ad33

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2989,7 +2989,14 @@ bool TupleContextualFailure::diagnoseAsError() {
29892989
diagnostic = diag::tuple_types_not_convertible_nelts;
29902990
else if ((purpose == CTP_Initialization) && !getContextualType(getAnchor()))
29912991
diagnostic = diag::tuple_types_not_convertible;
2992-
else if (auto diag = getDiagnosticFor(purpose, getToType()))
2992+
else if (purpose == CTP_AssignSource) {
2993+
auto assignExpr = castToExpr<AssignExpr>(getAnchor());
2994+
if (isa<SubscriptExpr>(assignExpr->getDest())) {
2995+
diagnostic = *getDiagnosticFor(CTP_SubscriptAssignSource, getToType());
2996+
} else {
2997+
diagnostic = *getDiagnosticFor(purpose, getToType());
2998+
}
2999+
} else if (auto diag = getDiagnosticFor(purpose, getToType()))
29933000
diagnostic = *diag;
29943001
else
29953002
return false;

0 commit comments

Comments
 (0)