Skip to content

Can't return from inside a block #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pcwalton opened this issue Mar 12, 2011 · 4 comments
Closed

Can't return from inside a block #270

pcwalton opened this issue Mar 12, 2011 · 4 comments

Comments

@pcwalton
Copy link
Contributor

iterFunc({|| ret; }) does not return from the outer function.

Maybe we'll just have accept this, since in the absence of non-local control flow, there's no nice way to implement such returns.

@brson
Copy link
Contributor

brson commented Jun 21, 2011

This translates now, but incorrectly, acting like a continue statement.

@ghost ghost assigned catamorphism Jul 20, 2011
@catamorphism
Copy link
Contributor

Here's a code example that reproduces it:

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.

@marijnh
Copy link
Contributor

marijnh commented Oct 21, 2011

Iterators are out. Rewording the bug title to apply to blocks.

@graydon
Copy link
Contributor

graydon commented Mar 5, 2012

Duplicated (in much more detail) by #1619, closing.

@graydon graydon closed this as completed Mar 5, 2012
dlrobertson pushed a commit to dlrobertson/rust that referenced this issue Nov 29, 2018
Document the <=0x7F restriction on \x escapes.
djtech-dev pushed a commit to djtech-dev/rust that referenced this issue Dec 9, 2021
carolynzech pushed a commit to carolynzech/rust that referenced this issue Mar 17, 2025
…ng#270)

repo-filter does not produce consistent SHA hashes. While we were aware
of this, we hadn't realized that this made incremental non-interactive
updates of the branch a matter of luck as git may or may not be able to
automatically resolve conflicts. (It worked for the update to
2025-02-10, but failed for the next one.)

git-subtree-split does produce consistent SHA hashes, but the native
`git-subtree-split` implementation is a shell script, and thus was found
to be too slow (which is why we chose repo-filter in the first place).

splitsh-lite is an implementation of just the `subtree split` command in
Go and libgit2. This makes `subtree split` even faster than
`repo-filter` at 35 seconds vs 50 seconds (on a GitHub runner).

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.
carolynzech pushed a commit to carolynzech/rust that referenced this issue Apr 17, 2025
…g#288)

This restores a fix from rust-lang#250 that was deemed no longer necessary with
the move to subtree split (in rust-lang#270), but this proved to be wrong. (See
model-checking@ab648fe
for such an example of an unintended change.)

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.

Co-authored-by: thanhnguyen-aws <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants