Default value for throwing closure argument of a rethrowing function

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)?

Regards,
Bhargav Gurlanka

This looks like a bug. We'd appreciate a bug report on bugs.swift.org if you have some time.

-Joe

···

On May 16, 2016, at 2:35 AM, bhargav gurlanka via swift-users <swift-users@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)?