[swift-evolution] [Review] SE-0047 Defaulting non-Void functions so they warn on unused results

Chris Lattner clattner at apple.com
Sun Mar 27 22:26:28 CDT 2016


> On Mar 27, 2016, at 6:33 AM, Maximilian Hünenberger via swift-evolution <swift-evolution at swift.org> wrote:
> 
> In the proposal there is no mention of generic functions.
> Take a map function of a Wrapper:
> 
> Wrapper<T> {
>        func map<U>(transform: T -> U) -> U { ... }
> }
> 
> let intWrapper = Wrapper(1)
> intWrapper.map{ print($0) } // this returns Void
> Should the last line be inferred to have a discardable result?

Yes, this will be inferred to return Void, so no warning will be produced.

-Chris


More information about the swift-evolution mailing list