[SR-6965] diagnostics bad when an unnecessary try is used in a non-throwing function #49513
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
diagnostics QoI
Bug: Diagnostics Quality of Implementation
type checker
Area → compiler: Semantic analysis
Attachment: Download
Additional Detail from JIRA
md5: 763c1623aca7cdb7cc554e887ab791ac
Issue Description:
I've just done a bit of refactoring and this happened a lot: I frequently had code like function
bar
clearly, I can just remove the unnecessary
try
inbar
and everything's good. However I didn't spot thetry
straight away and then I get a compilation error that I'm turning a throwing function into a non-throwing function.It shows both. But if there's errors, Xcode and possibly other IDEs prefer to show you the errors first and you can't spot the warning at all (see attached screenshot).
Given that the compiler already figured out that the
try
is unnecessary, it shouldn't infer the closure's type to have athrows
.Even if I help the type checker by telling it the full type
it still shows the same error 🙁
The text was updated successfully, but these errors were encountered: