Skip to content

Commit 4f39e3b

Browse files
Suyash SrijanSuyash Srijan
authored andcommitted
[silgen] [ast] adds param name to diagnostics
1 parent e8d3caa commit 4f39e3b

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ ERROR(guard_body_must_not_fallthrough,none,
230230
" to exit the scope", ())
231231
WARNING(unreachable_code,none, "will never be executed", ())
232232
NOTE(unreachable_code_uninhabited_param_note,none,
233-
"the function body will never be executed. remove the function body to dismiss "
234-
"the warning", ())
233+
"'%0' is uninhabited, so this function body can never be executed", (Identifier))
235234
NOTE(unreachable_code_branch,none,
236235
"condition always evaluates to %select{false|true}0", (bool))
237236
NOTE(call_to_noreturn_note,none,

lib/SILGen/SILGenProlog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ void SILGenFunction::emitProlog(AnyFunctionRef TheClosure,
437437
if (auto body = TheClosure.getBody()) {
438438
if (!body->getElements().empty()) {
439439
auto &ctx = SGM.M.getASTContext();
440-
ctx.Diags.diagnose(body->getStartLoc(), diag::unreachable_code_uninhabited_param_note);
440+
ctx.Diags.diagnose(body->getStartLoc(), diag::unreachable_code_uninhabited_param_note, param->getName());
441441
}
442442
}
443443
break;

test/SILGen/functions_uninhabited_param.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
//===--- Function declaration with uninhabited parameter type
44

5-
func foo(baz: Never) -> Int { // expected-note {{the function body will never be executed. remove the function body to dismiss the warning}}
5+
func foo(baz: Never) -> Int { // expected-note {{'baz' is uninhabited, so this function body can never be executed}}
66
print("I can't be called!") // expected-warning{{will never be executed}}
77
return 0
88
}

0 commit comments

Comments
 (0)