[swift-evolution] Make non-void functions @warn_unused_result by default

Tino Heth 2th at gmx.de
Fri Dec 18 06:13:25 CST 2015


> here's a short example that currently compiles without any warnings:
> 
> func thisFuncHasNoWarnings(a: Int) {
>     a
>     "b"
>     "c" as Character
>     1.0
>     [2.0, 3.0]
>     ["four", 5, 6.7] as [Any]
>     "Is this"; a; "problem?"
> }

And what would be the benefit of those warnings?
How about
for i in 1…1000000 {}
Equally stupid - should we have a warning for this as well?

Or
if (answer == true) {
…
} else if (answer == false) {
…
}
(really have seen something similar in the wild - I just don't remember if there has been an else clause as well ;-)

It is fine to aid inexperienced coders with concise warnings, but for me, the proposal is merely a burden for those who know what they are doing.
I wouldn't object against having the analyzer generate such warnings, though.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151218/fbadbe96/attachment.html>


More information about the swift-evolution mailing list