Skip to content

Non-local returns are not implemented #743

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
DarkDimius opened this issue Jul 28, 2015 · 3 comments
Closed

Non-local returns are not implemented #743

DarkDimius opened this issue Jul 28, 2015 · 3 comments

Comments

@DarkDimius
Copy link
Contributor

object NonLocalReturn {
 def foo(a: List[Int]): Int = {
   a.foreach(x => return x)
   0
  }
}

Return will reach backend as part of

    private def $anonfun$foo$1(x: Int): Nothing = return x

triggering an error:

assertion failed: Expected primitive types I - Lscala/runtime/Nothing$;
DarkDimius added a commit to dotty-staging/dotty that referenced this issue Jul 28, 2015
@DarkDimius
Copy link
Contributor Author

This phase is substantially easier to implement before ExpandSAMs has run, as after some functions will become anonymous classes.

@odersky
Copy link
Contributor

odersky commented Aug 4, 2015

@DarkDimius I would have thought the opposite is true. To find out whether a non-local return is needed it would be good if SAMs and by-name parameters were already expanded. Or am I missing something here?

@odersky
Copy link
Contributor

odersky commented Aug 4, 2015

Currently we are blocked on this by #746.

Edit: nevermind: I just generated the obvious Typed patterns and the backend did the right thing for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants