<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">The last line should be <span style="font-family:arial,sans-serif;font-size:12.800000190734863px"> `</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">fatalError(</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">findReasonAndTerminate())`.</span></div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Zhaoxin</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 24, 2017 at 5:13 PM, Zhao Xin <span dir="ltr"><<a href="mailto:owenzx@gmail.com" target="_blank">owenzx@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Change you `<span style="font-size:12.800000190734863px;font-family:arial,sans-serif">func findReasonAndTerminate()` to `</span><span style="font-size:12.800000190734863px;font-family:arial,sans-serif">func findReasonAndTerminate() -> String`.</span></div><div class="gmail_default"><span style="font-size:12.800000190734863px">Then you can use `</span><span style="font-size:12.800000190734863px">fatalError(</span><span style="font-size:12.800000190734863px">func findReasonAndTerminate())`.</span></div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-size:12.800000190734863px;font-family:arial,sans-serif"><br></span></div><div class="gmail_default"><span style="font-size:12.800000190734863px">Zhaoxin</span></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 24, 2017 at 5:02 PM, Rien via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Is there any way to mark a function as “no return”?<br>
<br>
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.<br>
<br>
func findReasonAndTerminate() {<br>
let reason: String = ….<br>
fatalError(reason)<br>
}<br>
<br>
main.swift:<br>
<br>
guard let data = buildData() else { findReasonAndTerminate() }<br>
<br>
<br>
Currently the work around is to add another fatalError like this:<br>
<br>
guard let data = buildData() else { findReasonAndTerminate(); fatalError }<br>
<br>
<br>
but it would be nice to have some attribute like @noReturn:<br>
<br>
@noReturn<br>
func findReasonAndTerminate() { … }<br>
<br>
<br>
Regards,<br>
Rien<br>
<br>
Site: <a href="http://balancingrock.nl" rel="noreferrer" target="_blank">http://balancingrock.nl</a><br>
Blog: <a href="http://swiftrien.blogspot.com" rel="noreferrer" target="_blank">http://swiftrien.blogspot.com</a><br>
Github: <a href="http://github.com/Balancingrock" rel="noreferrer" target="_blank">http://github.com/Balancingroc<wbr>k</a><br>
Project: <a href="http://swiftfire.nl" rel="noreferrer" target="_blank">http://swiftfire.nl</a><br>
<br>
<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-users</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>