-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Fix Expr conversion of erroneous operator dot call #374
Conversation
Codecov Report
@@ Coverage Diff @@
## main #374 +/- ##
=======================================
Coverage 96.58% 96.58%
=======================================
Files 14 14
Lines 4160 4161 +1
=======================================
+ Hits 4018 4019 +1
Misses 142 142
|
Awesome, thanks for the PR! As for the appropriate julia> parsestmt(SyntaxNode, ".+julia", ignore_errors=true)
line:col│ tree │ file_name
1:1 │[dotcall-pre]
1:2 │ +
1:3 │ julia
julia> dump(Expr(parsestmt(SyntaxNode, ".+julia", ignore_errors=true)))
Expr
head: Symbol call
args: Array{Any}((2,))
1: Symbol .+
2: Symbol julia And we have the following tree for julia> parsestmt(SyntaxNode, "./julia", ignore_errors=true)
line:col│ tree │ file_name
1:1 │[dotcall-pre]
1:1 │ [error]
1:1 │ [.]
1:2 │ /
1:3 │ julia
|
That's perfectly sensible: done in bea7bae, thanks for the correction! Another question: should I assert that Lines 276 to 278 in bea7bae
i.e. change the comment into an else clause that errors if startsym is not an Expr(:error, ...) ? I don't know if the current policy is to eagerly error when encountering unexpected expressions at that point of the parser, or letting them flow.
|
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.
Thanks! I've noted a couple more minor quibbles, but I think this is basically good to go.
I'm in two minds about asserting that the else
should be an Expr(:error)
. On the one hand, the parser shouldn't create any other forms. But on the other hand, people can construct SyntaxNode
s programmatically and it might make sense just to convert them rather than throw. I don't really know what's best. Maybe leave as-is :-)
Co-authored-by: Claire Foster <aka.c42f@gmail.com>
Co-authored-by: Claire Foster <aka.c42f@gmail.com>
Thanks for the review, much better now! |
Looks lovely, thank youu :) |
Thank you for all the help! |
Fix #341
The root issue was the unconditional conversion of an
Expr(:dotcall, foo, ...)
toExpr(:call, Symbol(:., foo), ...)
whenfoo
was not anExpr(:., ...)
. That case corresponds to dotted operators (wherefoo
is the symbol of the operator), but it can actually also occur when there is a parsing error, such as misplacing a non-unitary dotted operator like in the MWE.I'm not completely sure what
Expr
should be yielded here, I went forExpr(:dotcall, Expr(:error, Expr(:., foo), ...)
because it required minimal change, but let me know if it should be something else!