-
-
Notifications
You must be signed in to change notification settings - Fork 79
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 function isdef #173
fix function isdef #173
Conversation
|
||
islongdef(ex) = @capture(ex, function (fcall_ | fcall_) body_ end) |
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.
This way of checking if an expression is a long function definition is taken from here:
here
However, it seems to me that the or statement has no effect and the following would be equivalent:
islongdef(ex) = @capture(ex, function fcall_ body_ end)
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 also wonder about the |
... odd...
Independently of that, maybe also change https://github.com/FluxML/MacroTools.jl/blob/master/src/utils.jl#L298-L300 to use islongdef
?
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.
Good catch, indeed, 69f5811 shows that I'm the one who changed a more complex |
expression to this (fcall_ | fcall_)
. I'm going to guess that I did that purely because this is complex code and I wanted to play it safe.
Long story short: please try it without the |
, and if all tests pass, we'll keep it like that.
@cstjean, can you review and merge this? |
It's on my todo list, but it may take a few more weeks, with covid... Sorry |
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.
Could you please add negative examples to the test suite for isdef
, to show that this PR is more correct? Particularly interested in function foo end
(should that be a function definition? I think not), but others would be nice too.
We should probably check the docs. I'd call it function declaration, but if the docs say otherwise... |
The proposed function
seems to work (although I don't fully understand why). Replacing However, I think there is a problem with
plus variants with argument type annotations, return type annotations and |
Right - those would all be good test cases for whoever takes up the baton on this PR. |
I could give it a try. Do you insist on using
Of course, this doesn't check whether |
As long as the tests have good coverage, I don't think we need to worry about malformed expressions. |
fixes #172