Skip to content

Commit be26b83

Browse files
committed
Make the argument-label diagnostics slightly more robust.
If we're matching the trailing closure at the end but haven't seen any mismatches yet, consider the trailing closure to be a mismatch. This function probably needs to be rewritten in terms of matchCallArguments(), because it is performing an incorrect approximation of label matching that doesn't work for multiple trailing closures.
1 parent d736586 commit be26b83

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/Sema/MiscDiagnostics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1798,7 +1798,8 @@ bool swift::diagnoseArgumentLabelError(ASTContext &ctx,
17981798
newName = newNames[i];
17991799

18001800
if (oldName == newName ||
1801-
(argList.hasTrailingClosure && i == argList.args.size()-1))
1801+
(argList.hasTrailingClosure && i == argList.args.size()-1 &&
1802+
(numMissing > 0 || numExtra > 0 || numWrong > 0)))
18021803
continue;
18031804

18041805
if (oldName.empty()) {

0 commit comments

Comments
 (0)