Skip to content

Commit 28452fd

Browse files
committed
expression_unused_result_unknown diagnostic recognize closures
for any call that is applied to a name i.e. name() the diagnostic will use 'function' for calls to anonymous functions i.e {...}() the diagnostic will use 'closure'
1 parent 2d37507 commit 28452fd

File tree

3 files changed

+3
-786
lines changed

3 files changed

+3
-786
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2893,7 +2893,7 @@ WARNING(expression_unused_result_call,none,
28932893
WARNING(expression_unused_result_operator,none,
28942894
"result of operator %0 is unused", (DeclName))
28952895
WARNING(expression_unused_result_unknown, none,
2896-
"result of call to function returning %0 is unused", (Type))
2896+
"result of call to %select{function|closure}0 returning %1 is unused", (bool, Type))
28972897
WARNING(expression_unused_result, none,
28982898
"expression of type %0 is unused", (Type))
28992899
WARNING(expression_unused_init_result,none,

lib/Sema/TypeCheckStmt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,9 +1322,9 @@ void TypeChecker::checkIgnoredExpr(Expr *E) {
13221322
.highlight(SR1).highlight(SR2);
13231323
} else
13241324
diagnose(fn->getLoc(), diag::expression_unused_result_unknown,
1325-
valueE->getType())
1325+
isa<ClosureExpr>(fn), valueE->getType())
13261326
.highlight(SR1).highlight(SR2);
1327-
1327+
13281328
return;
13291329
}
13301330

0 commit comments

Comments
 (0)