Skip to content

Commit df0616a

Browse files
committed
[CSDiag] Mark all sub-expressions which are about to be re-typechecked
Currently that has been limited only to expressions which aren't flagged as `TCC_ForceRecheck`, but it should be extended to all sub-expressions, otherwise we might produce invalid diagnostics in `PreCheckExpression`.
1 parent fe9376d commit df0616a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,10 +1753,11 @@ Expr *FailureDiagnosis::typeCheckChildIndependently(
17531753
CS.cacheExprTypes(savedExpr);
17541754
return savedExpr;
17551755
}
1756-
1757-
CS.TC.addExprForDiagnosis(subExpr, subExpr);
17581756
}
17591757

1758+
// Mark current expression as about to be diagnosed.
1759+
CS.TC.addExprForDiagnosis(subExpr, subExpr);
1760+
17601761
// Validate contextual type before trying to use it.
17611762
std::tie(convertType, convertTypePurpose) =
17621763
validateContextualType(convertType, convertTypePurpose);
@@ -5651,6 +5652,15 @@ bool FailureDiagnosis::visitAssignExpr(AssignExpr *assignExpr) {
56515652
return true;
56525653
}
56535654

5655+
// Situation like `var foo = &bar` didn't get diagnosed early
5656+
// because originally its parent is a `SequenceExpr` which hasn't
5657+
// been folded yet, and could represent an operator which accepts
5658+
// `inout` arguments.
5659+
if (auto *AddrOf = dyn_cast<InOutExpr>(assignExpr->getSrc())) {
5660+
diagnose(AddrOf->getLoc(), diag::extraneous_address_of);
5661+
return true;
5662+
}
5663+
56545664
if (CS.TC.diagnoseSelfAssignment(assignExpr))
56555665
return true;
56565666

0 commit comments

Comments
 (0)