Skip to content

indentation region after return keyword is not recognized #11802

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
unkarjedy opened this issue Mar 18, 2021 · 4 comments · Fixed by #11752
Closed

indentation region after return keyword is not recognized #11802

unkarjedy opened this issue Mar 18, 2021 · 4 comments · Fixed by #11752
Milestone

Comments

@unkarjedy
Copy link
Contributor

Compiler version

3.0.0-RC2-bin-20210317-758782a-NIGHTLY

Minimized code

def bar2: Int = {
  println(1)
  println(2)
  return
    var x = 1
    var y = 1
    x + y
}

bar2

Output

return              
^^^^^^              
Found:    Unit      
Required: Int       

image

Expectation

According to:
http://dotty.epfl.ch/docs/reference/other-new-features/indentation.html#optional-braces

... an indentation region can start ... after one of the following tokens:
... return ...

So the code should compile, or the reference should be adjusted.

@unkarjedy
Copy link
Contributor Author

If you extract the return result to a variable it works:

image

Though the output is badly-sorted: def bar2: Int should go before function call (REPL issue?)

@abgruszecki
Copy link
Contributor

@unkarjedy did the output look different in Scala2? I don't think there's much we can do about that particular part, considering that one can define multiple vals in one REPL input...

@som-snytt
Copy link
Contributor

I recently revisited a closed scala 2 ticket about order of REPL output, which at least demonstrates that there are differing expectations. scala/bug#10893

@odersky odersky linked a pull request Mar 19, 2021 that will close this issue
4 tasks
@odersky
Copy link
Contributor

odersky commented Mar 19, 2021

This will be fixed by #11752

@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants