<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Indeed, you're right. If the do or if is nested within a loop the break works on the loop instead of the do/if.<div class=""><br class=""></div><div class="">Austin<br class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 10, 2015, at 11:12 AM, Kevin Ballard via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<title class=""></title>
<div class=""><div class="">On Thu, Dec 10, 2015, at 11:05 AM, Austin Zheng via swift-evolution wrote:<br class=""></div>
<blockquote type="cite" class=""><div dir="ltr" class=""><div class="">Unlabeled "break" within a do is a compiler error, even if the do is nested within a different control flow.<br class=""></div>
</div>
</blockquote><div class=""> </div>
<div class="">No it's not. The following compiles just fine (in Swift 2.1 and Swift 2.2-dev):<br class=""></div>
<div class=""> </div>
<div class=""><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;">repeat {</span><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><br class=""></span></div>
<div class=""><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"> do {</span><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><br class=""></span></div>
<div class=""><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"> break</span><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><br class=""></span></div>
<div class=""><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"> }</span><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><br class=""></span></div>
<div class=""><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;">} while true</span><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><br class=""></span></div>
<div class=""><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;">print("done")<br class=""></span><br class=""></div>
<div class="">But I don't think that's a problem. There's tons of precedent for unlabelled break breaking out of the nearest enclosing loop rather than the nearest enclosing scope. And people are generally going to learn about unlabelled break before labelled break. The fact that you can label a do {} and break out of it is interesting, but shouldn't change the expected behavior of unlabelled break.<br class=""></div>
<div class=""> </div>
<div class="">-Kevin Ballard<br class=""></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=7XtDdMHRjqIUi4tzSjSp2pWQIyxYdP6woIWn4vwV5gcAT2rfYgpYOV63r1Noh3UhYwcbJGwG-2BaeTZCVhEC1q1TgJmcl4iVxyUtM61MN-2FK3MZXZHz09G8Mokj6ndOVzWVM6lBS-2FcC3VEYW4qVXO80AssNsdQZEB8DkcMCUDnRRHPpjTxEzQMrsVuaTHeJYqmw6vs9F3sxenqxGw7McF04HJzaVOP5Zgb1OazmSivWbIs-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></div></body></html>