-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Check trailing blank line at EOF for OUTDENT #22855
Conversation
ab9caa0
to
1d740e9
Compare
An adjustment is required.
where Also the scripted test does not actually pass. In |
1d740e9
to
eb2c406
Compare
Dotty ReplTest does only single-line inputs; at least "scripted" test should work like Scala 2 The gold standard integration test would run a REPL process from test input, in order to test incomplete input:
The JLine parser could be tested for internal behavior, but scripted or "session" tests are easier to create and read. |
eb2c406
to
475b235
Compare
475b235
to
477d593
Compare
The failure was the flaky cats test. Of course, dog people know that all cats are flaky. |
477d593
to
70c7af2
Compare
@mbovel @hamzaremmal Looks like this is ready to review, anyone could take a look? |
Yes, I can have a look tomorrow 👍 |
Let me try to summarize. Consider the following snippet without a trailing line break (i.e., the last three tokens are object Foo:
••val foo = 42
•
Is my understanding correct? If yes, then the implementation looks correct to me! 🙂 |
Out of curiosity, I also checked what happens when a non-empty blank line is not at the end—for example, when the trailing four tokens are |
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.
Minor: I would not include 7fefe7f, a commit that only reformats code. The improvement looks subjective to me. The removal of removeNumberSeparators
or the loss of indentation for case
s in isIncomplete
actually make the code harder to read for me. Such changes also pollute git blame
.
Thanks for your review effort! I will also try to understand my code and clean it up. I'm not wedded to the first commit, which I see as scouting. I think "match-aligned case" is the future, but the future doesn't have to be now. Ah yes, to rephrase, the additional condition The change to |
70c7af2
to
ce4d8de
Compare
|
Check trailing blank line at EOF for OUTDENT If EOF is preceded by only spaces on the last line, do not outdent because it will complain about alignment during an edit. Preserve EOF token when probing arrow EOL For REPL, `: x =>` at EOF sees an EOF in order to detect lambda eol.
ce4d8de
to
268b325
Compare
) Backports #22855 to 3.7.0-RC2
Boost the previous fix for "spurious indentation error for blank line at EOF" by checking that the line is a non-empty blank line.
This accommodates REPL, which routinely parses lines at EOF.
Also improve the previous fix for "correctly detect colon arrow at EOL" by returning token EOF at EOF. The check for EOF when probing whether
followingIsLambaAfterColon
was specifically to accommodate REPL.Fixes #22844