[swift-users] Default value for throwing closure argument of a rethrowing function
Joe Groff
jgroff at apple.com
Mon May 16 12:10:35 CDT 2016
> On May 16, 2016, at 2:35 AM, bhargav gurlanka via swift-users <swift-users at swift.org> wrote:
>
> Hi all,
>
> Could someone please tell me why the following fails?
>
> func foo(f: () throws -> () = {}) rethrows {
> try f()
> }
>
> // Fine
> foo({ })
>
> // This fails with error:
> // call is to 'rethrows' function,
> // but a defaulted argument function can throw
> foo()
>
> Why should I have to write "try foo()", shouldn't it take the default value (non throwing closure)?
This looks like a bug. We'd appreciate a bug report on bugs.swift.org if you have some time.
-Joe
More information about the swift-users
mailing list