<!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> </div>
<div>No it's not. The following compiles just fine (in Swift 2.1 and Swift 2.2-dev):<br></div>
<div> </div>
<div><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></span></div>
<div><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></span></div>
<div><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></span></div>
<div><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></span></div>
<div><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></span></div>
<div><span class="font" style="font-family: menlo, consolas, "courier new", 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> </div>
<div>-Kevin Ballard<br></div>
</body>
</html>