-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Print double breaks after statements to avoid ambiguity #4689
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
Print double breaks after statements to avoid ambiguity #4689
Conversation
80be1cc
to
63421c4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise, LGTM
this += ";" | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a blank line instead of ;
?
Also, it seems it's only needed if the previous tree may cause ambiguity. This can be an improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be implemented but it would require knowing which is the next tree is printed and how it will be printed. This solution is much simpler, homogenous and less bug-prone. I will try to remove them in the future once I have a complete test suite.
Using by default an additional blank line add too many lines. I would consider if we only print it when needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add ;
all the time? Looking at the diff, I find it a bit weird that sometime a statement ends with ;
and sometime not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it at the end of all statements. The expression at the end of the block does not need it. Look at it as a separator.
Still later I will work on making the format nicer to look at. For now the main goal is corecness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a blank line instead. Writing semicolons is just so weird when looking at Scala code. I believe there is an easy way to add blank lines: When you print a statement sequence, add blank line in front of every Block
node, except if it is the first statement.
c91c182
to
57b9a51
Compare
;
at the end of statements to avoid ambiguity57b9a51
to
daea935
Compare
Changed to line breaks
@liufengyun could you re-review this PR |
For example, the first snippet is `foo.apply(...)` and the second is eval `foo` and then eval the block. ```scala foo { ... } ``` ```scala foo { ... } ```
daea935
to
d5d991d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
For example, the first snippet is
foo.apply(...)
and the second iseval
foo
and then eval the block.