-
Notifications
You must be signed in to change notification settings - Fork 11
make kwarg-methods whereis as nothing, rather than as ("none",0) #48
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
Conversation
# kwargs that result in not finding the file | ||
m = @which sum([1]; dims=1) | ||
loc = whereis(m) | ||
@test loc != ("none", 0) # old incorrect behavour. |
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 test is redundant with the one below.
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 is indeed, but it serves to illustrate what was wrong before.
It can be removed, but I thought it might be helpful in future changes.
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.
Do you think it should be removed?
@test loc != ("none", 0) # old incorrect behavour. |
src/CodeTracking.jl
Outdated
Return a string with the code that defines `method`. Also return the first line of the | ||
definition, including the signature (which may not be the same line number returned | ||
by `whereis`). | ||
If the method could not be found for some reason, returns `nothing`. |
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.
If the method could not be found for some reason, returns `nothing`. | |
If the method could not be found for some reason, then return `nothing`. |
Co-Authored-By: Kristoffer Carlsson <kristoffer.carlsson@chalmers.se>
Codecov Report
@@ Coverage Diff @@
## master #48 +/- ##
====================================
Coverage 0% 0%
====================================
Files 3 3
Lines 165 169 +4
====================================
- Misses 165 169 +4
Continue to review full report at Codecov.
|
Co-Authored-By: Kristoffer Carlsson <kristoffer.carlsson@chalmers.se>
The better approach is to fix the underlying problem. In this case the issue is julia> m
(::getfield(Base, Symbol("#kw##sum")))(::Any, ::typeof(sum), a::AbstractArray) in Base
julia> m.file
:none which makes it impractical to find it. However, with a suitably-fixed version of julia> mbody = LoweredCodeUtils.bodymethod(m)
#sum#558(dims, ::typeof(sum), a::AbstractArray) in Base at /home/tim/src/julia-1/base/reducedim.jl:652 and voila we have it. I'll submit the PRs (LCU, CodeTracking, and Revise) needed to make this work. I'm not against this change, but I am about to invalidate your test 😄. |
@timholy great to have this fixed properly. |
I'd call this graceful: julia> whereis(@which sum([1]; dims=1))
("none", 0) |
I would not call that graceful, because potentially Further |
But no actual method has a line number of 0. (Internally, Julia checks this kind of thing fairly frequently.) You can also use The |
That sounds like a reasonable argument for the current behavour.
I think so. |
Before:
After, both of these return
nothing
.