Skip to content

REPL should work with optional braces #8762

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
odersky opened this issue Apr 21, 2020 · 0 comments · Fixed by #8765
Closed

REPL should work with optional braces #8762

odersky opened this issue Apr 21, 2020 · 0 comments · Fixed by #8765

Comments

@odersky
Copy link
Contributor

odersky commented Apr 21, 2020

I want to be able to write in the REPL

scala> if true then
  print(1)
  printl2)

and get "12" printed. But right now, it prints 1 immediately.

scala> if true then                                                                                                
     |   print(1)
1

To make this work, the REPL should continue to read indented code until it encounters a line that starts further to the left, or a blank line. Otherwise put, any line that has the same or larger indendation margin as the first line after the then should be seen as a follow-on.

odersky added a commit to dotty-staging/dotty that referenced this issue Apr 22, 2020
This is great even if we do not use optional braces. For instance, now you can write:
```scala
scala> if c == 1 then
  "yes"
else
  "no"
```
Previously, it would have stopped you after the "yes".
odersky added a commit to dotty-staging/dotty that referenced this issue Apr 22, 2020
This is great even if we do not use optional braces. For instance, now you can write:
```scala
scala> if c == 1 then
  "yes"
else
  "no"
```
Previously, it would have stopped you after the "yes".
anatoliykmetyuk added a commit that referenced this issue Apr 22, 2020
Fix #8762: Make REPL work with indented code
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

Successfully merging a pull request may close this issue.

1 participant