<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Did you try an example? Swift warns about this for this very reason:<div class="">```</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">$ cat x.swift </div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">func f0() {}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">func f1() {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> return</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> f0()</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">$ swiftc -c x.swift </div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">x.swift:5:3: </b></span><span style="font-variant-ligatures: no-common-ligatures; color: #d53bd3" class=""><b class="">warning: </b></span><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">expression following 'return' is treated as an argument of the 'return'</b></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> f0()</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(52, 189, 38);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class=""> ^</b></span></div><div class="">```</div><div class=""><br class=""></div><div class=""> - Daniel</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 6, 2016, at 10:00 AM, Jens Alfke via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Someone on another forum (not directly related to Swift) just mentioned running into a confusing situation where they had added an early `return` to a method for testing purposes, in order to disable the code following it:</div><div class=""><br class=""></div><div class=""><div class="">func myFunc() {</div><div class=""> // some code</div><div class=""> return</div><div class=""> cache.removeAll()</div><div class=""> // more code that is now skipped.</div><div class="">}</div></div><div class=""><br class=""></div><div class="">Unexpectedly, the line following the `return` still got executed, so "I couldn't figure out why my cache kept getting zapped.”</div><div class=""><br class=""></div><div class="">Turns out the Swift parser is interpreting this as `return cache.removeAll()`, which works because that expression returns void, which matches the function’s return type.</div><div class=""><br class=""></div><div class="">This seems like a case where the parser is playing by the rules, but the result is not what a human would expect. It would be better for a `return` on a line by itself to be parsed as a complete statement, without continuing to the next line. Is this already a known issue?</div><div class=""><br class=""></div><div class="">—Jens</div><div style="font-size: 14px;" class=""><br class=""></div><div style="font-size: 14px;" class="">PS: I’m sure someone will point out that adding an early return like this is sub-optimal, and the compiler could warn that the code following is unreachable. Which is true, and I use comments to disable code in situations like this. But I’m sure this developer’s not the only one who adds `return` instead.</div></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></body></html>