[swift-users] @noReturn

Rien Rien at Balancingrock.nl
Fri Mar 24 04:02:25 CDT 2017

Is there any way to mark a function as “no return”?

Reason: The compiler generates an error when the else block from a guard does not terminate the execution by either a return or a fatalError. I want to call out to a function and raise the fatalError in that function.

func findReasonAndTerminate() {
   let reason: String = ….


guard let data = buildData() else { findReasonAndTerminate() }

Currently the work around is to add another fatalError like this:

guard let data = buildData() else { findReasonAndTerminate(); fatalError }

but it would be nice to have some attribute like @noReturn:

func findReasonAndTerminate() { … }


Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl

More information about the swift-users mailing list