You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-1534 Error: Call is to rethrows function, but a defaulted argument function can throw
Issue Description:
If I write a rethrowing function that takes a possibly throwing closure and provide a non-throwing default value, I have to use 'try' when calling that function without an argument. Is this the right behavior? The compiler should be aware that the default closure doesn't throw, so it would be nice if the "default" function call wasn't marked as rethrowing:
funcfoo(_f: () throws -> Void = { print("Hello!") }) rethrows {
tryf()
}
foo({ print("Hey!") })
// Hey!foo()
// error: call can throw but is not marked with 'try'// note: call is to 'rethrows' function, but argument function can throwtryfoo()
// Hello!
The text was updated successfully, but these errors were encountered:
Currently default arguments are provided by the caller, not the callee, which means that the default value could change in a later version of the library. That's the reasoning behind the current rule, anyway—clearly in this case the function is in the same module.
We should fix this at the point where we change default arguments to be inlined emitted into the current module.
Environment
swift/master
Additional Detail from JIRA
md5: cb9111257bd7df15f0c96606bf6fc98a
duplicates:
Issue Description:
If I write a rethrowing function that takes a possibly throwing closure and provide a non-throwing default value, I have to use 'try' when calling that function without an argument. Is this the right behavior? The compiler should be aware that the default closure doesn't throw, so it would be nice if the "default" function call wasn't marked as rethrowing:
The text was updated successfully, but these errors were encountered: