You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use std;
import std::uint;
fn foo() {
for each (uint i in uint::range(0u, 10u)) {
if (i > 5u) {
ret;
}
}
fail "Shouldn't have reached this point";
}
fn main() {
foo();
log_err "Okay!";
}
The problem is that the ret inside the for-each loop is returning from the closure that trans generates automatically for the loop body, not from foo. That's why it acts like a continue.
I was going to try fixing this, but it's not obvious to me how to (there's no other case when you're returning from more than one nested scope at once), so I'm changing it back to unassigned.
Activity
brson commentedon Jun 21, 2011
This translates now, but incorrectly, acting like a continue statement.
catamorphism commentedon Jul 20, 2011
Here's a code example that reproduces it:
The problem is that the ret inside the for-each loop is returning from the closure that trans generates automatically for the loop body, not from foo. That's why it acts like a continue.
I was going to try fixing this, but it's not obvious to me how to (there's no other case when you're returning from more than one nested scope at once), so I'm changing it back to unassigned.
marijnh commentedon Oct 21, 2011
Iterators are out. Rewording the bug title to apply to blocks.
graydon commentedon Mar 5, 2012
Duplicated (in much more detail) by #1619, closing.
Merge pull request rust-lang#270 from alercah/escape
Merge pull request rust-lang#270 from seanyoung/wasm
Subtree update automation: use fast version of subtree split (rust-la…
Subtree update automation: remove extraneous library folder (rust-lan…
feat: add TEA cipher (rust-lang#270)
Merge rust-lang#270
Auto merge of rust-lang#270 - Amanieu:gha, r=Amanieu