<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>On Thu, Dec 10, 2015, at 11:05 AM, Austin Zheng via swift-evolution wrote:<br></div>
<blockquote type="cite"><div dir="ltr"><div>Unlabeled "break" within a do is a compiler error, even if the do is nested within a different control flow.<br></div>
</div>
</blockquote><div>&nbsp;</div>
<div>No it's not. The following compiles just fine (in Swift 2.1 and Swift 2.2-dev):<br></div>
<div>&nbsp;</div>
<div><span class="font" style="font-family: menlo, consolas, &quot;courier new&quot;, monospace, sans-serif;">repeat {</span><span class="font" style="font-family: menlo, consolas, &quot;courier new&quot;, monospace, sans-serif;"><br></span></div>
<div><span class="font" style="font-family: menlo, consolas, &quot;courier new&quot;, monospace, sans-serif;">&nbsp; &nbsp; do {</span><span class="font" style="font-family: menlo, consolas, &quot;courier new&quot;, monospace, sans-serif;"><br></span></div>
<div><span class="font" style="font-family: menlo, consolas, &quot;courier new&quot;, monospace, sans-serif;">&nbsp; &nbsp; &nbsp; &nbsp; break</span><span class="font" style="font-family: menlo, consolas, &quot;courier new&quot;, monospace, sans-serif;"><br></span></div>
<div><span class="font" style="font-family: menlo, consolas, &quot;courier new&quot;, monospace, sans-serif;">&nbsp; &nbsp; }</span><span class="font" style="font-family: menlo, consolas, &quot;courier new&quot;, monospace, sans-serif;"><br></span></div>
<div><span class="font" style="font-family: menlo, consolas, &quot;courier new&quot;, monospace, sans-serif;">} while true</span><span class="font" style="font-family: menlo, consolas, &quot;courier new&quot;, monospace, sans-serif;"><br></span></div>
<div><span class="font" style="font-family: menlo, consolas, &quot;courier new&quot;, monospace, sans-serif;">print("done")<br></span><br></div>
<div>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></div>
<div>&nbsp;</div>
<div>-Kevin Ballard<br></div>
</body>
</html>