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

Marc Knaup marc at knaup.koeln
Fri Dec 11 17:36:40 CST 2015


Related to this change it would be great when ignoring a closure returned
by a function would become a warning instead of an error.

On Sat, Dec 12, 2015 at 12:26 AM, Douglas Gregor via swift-evolution <
swift-evolution at swift.org> wrote:

>
> On Dec 10, 2015, at 4:49 PM, Dmitri Gribenko via swift-evolution <
> swift-evolution at swift.org> wrote:
>
> On Thu, Dec 10, 2015 at 4:47 PM, Adrian Kashivskyy
> <adrian.kashivskyy at me.com> wrote:
>
> I'm sure there are plenty of methods in Foundation that return a value
> which
> can be ignored. However, as Joe noticed, such functions are generally in
> minority.
>
> I'd rather see a couple of `@allow_unused_result` than a dozen of
> `@warn_unused_result`.
>
>
> We are interested in seeing the actual data.
>
>
> Indeed, this change has the potential to produce a huge number of warnings
> that would not be appreciated by the majority of Swift programmers. One can
> go ahead and hack the Swift compiler fairly easily and go build some apps
> to see just how often the warning fires. The place to change in the source
> is in
>
> https://github.com/apple/swift/blob/master/lib/Sema/TypeCheckDecl.cpp
>
> so that we always diagnose calls to non-Void functions. It should be an
> easy one-off change to gather data.
>
> - Doug
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151212/47febfbf/attachment.html>


More information about the swift-evolution mailing list