-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Consider newlines as spaces for space-sensitive parsing #20265
Conversation
Looks good to me, but @JeffBezanson should probably take a look, too. |
Note that #16594 occurred only for the special case of operators that are parsed as both unary and binary, so a more conservative version of this PR would just change the |
This issue manifested in a different way for colon. It's minor, but the new behaviour is better. Before: julia> [1 :
2]
1×2 Array{Int64,2}:
1 2 Now: julia> [1 :
2]
ERROR: syntax: line break in ":" expression (this case is tested) As for Old julia> :(@test 1 ~
2)
ERROR: syntax: missing comma or ) in argument list New julia> :(@test 1 ~
2)
:(@test @~(1,2)) |
e3e8b5f
to
5a03a71
Compare
5a03a71
to
c70b231
Compare
The initial version of this PR was incorrect, leading to test failures. I have corrected this PR. |
Failure is macOS-only. Probably unrelated. |
bump @JeffBezanson |
Jeff, please review, do we want this one or not? |
Bump. |
This example from the linked issue seems like the biggest problem:
(where the trailing space on the first line makes a difference). I wonder if it's possible to fix just that? |
I fixed the merge conflict. |
The change seems pretty reasonable to me. Breaking, but unlikely to affect working real-world code. It is 11th hour but this one has been hanging around for a decision for a while… |
Failure is real—does not pass parsing tests. |
I think the issue is that the introduced |
Hold on, it looks like all the test failures are precisely the added tests (which are testing the issue that this fixes) which have bitrotted over time. The argument count for each of them is precisely off by one because the macro syntax has changed. The string one must have had a few extra quotes once upon a time. Let's see if the new commit fixes it. |
The |
One last test it looks like... This one because of ParseError binding deprecation. |
@StefanKarpinski good to go now? |
macOS failure is #26725. This isn't my call—@JeffBezanson will have to take a look and decide. |
test/parse.jl
Outdated
1).args) == 3 | ||
@test length(:(@x 1 + | ||
1 + | ||
1).args) == 3 |
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 would prefer these tests to check more than just the number of arguments.
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.
Yeah, just check Expr equality?
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.
OK, I have improved the tests using @stevengj's suggestion.
Fix #16594 by treating newlines, tabs, etc. as spaces that make binary parsing take precedence over unary parsing in space-sensitive situations.
cc @stevengj