mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
fix <rdar://problem/21553065> Spurious diagnostic: '_' can only appear in a pattern or on the left side of an assignment
... by reimplementing the DiscardAssignmentExpr checker in MiscDiagnostics instead of being in CSApply (which gets run on partial expression ASTs). Also, when type checking and salvaging an expression fails, do not generate structural diagnostics in addition to the type checker diagnostics, they are just noise. Swift SVN r29937
This commit is contained in:
@@ -5987,14 +5987,10 @@ namespace {
|
||||
|
||||
// Track whether we're in the left-hand side of an assignment...
|
||||
if (auto assign = dyn_cast<AssignExpr>(expr)) {
|
||||
++LeftSideOfAssignment;
|
||||
|
||||
if (auto dest = assign->getDest()->walk(*this))
|
||||
assign->setDest(dest);
|
||||
else
|
||||
return { false, nullptr };
|
||||
|
||||
--LeftSideOfAssignment;
|
||||
|
||||
auto &cs = Rewriter.getConstraintSystem();
|
||||
auto srcLocator = cs.getConstraintLocator(
|
||||
@@ -6009,12 +6005,7 @@ namespace {
|
||||
expr = Rewriter.visitAssignExpr(assign, srcLocator);
|
||||
return { false, expr };
|
||||
}
|
||||
|
||||
// ...so we can verify that '_' only appears there.
|
||||
if (isa<DiscardAssignmentExpr>(expr) && LeftSideOfAssignment == 0)
|
||||
Rewriter.getConstraintSystem().getTypeChecker()
|
||||
.diagnose(expr->getLoc(), diag::discard_expr_outside_of_assignment);
|
||||
|
||||
|
||||
Rewriter.walkToExprPre(expr);
|
||||
return { true, expr };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user