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

Jens Persson jens at bitcycle.com
Fri Dec 18 03:32:36 CST 2015

> strong +1 from me.  @warn_unused_result is almost always the right answer
> in the standard library, and the few cases where it isn’t are very easy to
> notice (when the call has side-effects and the return value is incidental).
> -Dave

I'm also in favour of this proposal.

Some days ago, in the swift-dev list (
) I was advised by Chris Lattner to bring a related issue into this

It's about the lack of a warning for simple statements that are unused and
thus meaningless (so most probably unintentional). To demonstrate what I
mean, here's a short example that currently compiles without any warnings:

func thisFuncHasNoWarnings(a: Int) {
    "c" as Character
    [2.0, 3.0]
    ["four", 5, 6.7] as [Any]
    "Is this"; a; "problem?"

I think it might be reasonable to expect a warning on every single line of
that function, no?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151218/45497780/attachment.html>

More information about the swift-evolution mailing list