Skip to content
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

Line information is wrong for structs using Parameters.jl #137

Open
ikirill opened this issue Jan 31, 2021 · 2 comments · May be fixed by #139
Open

Line information is wrong for structs using Parameters.jl #137

ikirill opened this issue Jan 31, 2021 · 2 comments · May be fixed by #139

Comments

@ikirill
Copy link

ikirill commented Jan 31, 2021

methods(LineSearches.HagerZhang) gives:

# 5 methods for type constructor:
(::Type{LineSearches.HagerZhang})(; delta, sigma, alphamax, rho, epsilon, gamma, linesearchmax, psi3, display, mayterminate) in LineSearches at /home/kirill/.julia/packages/Parameters/cGriM/src/Parameters.jl:520
(::Type{LineSearches.HagerZhang})(pp::LineSearches.HagerZhang; kws...) in LineSearches at /home/kirill/.julia/packages/Parameters/cGriM/src/Parameters.jl:530
(::Type{LineSearches.HagerZhang})(pp::LineSearches.HagerZhang, di::AbstractDict) in LineSearches at /home/kirill/.julia/packages/Parameters/cGriM/src/Parameters.jl:533
(::Type{LineSearches.HagerZhang})(pp::LineSearches.HagerZhang, di::Tuple{Symbol,Any}...) in LineSearches at /home/kirill/.julia/packages/Parameters/cGriM/src/Parameters.jl:534
(::Type{LineSearches.HagerZhang})(delta::T, sigma::T, alphamax::T, rho::T, epsilon::T, gamma::T, linesearchmax, psi3::T, display, mayterminate::Tm) where {T, Tm} in LineSearches at /home/kirill/.julia/packages/Parameters/cGriM/src/Parameters.jl:501

and the file line information is all wrong because it's taking it from the definition macro, not the original definition.

One reason this matters is that methods(f) is a way to find out precisely where f is defined, even in the presence of multiple package versions in Julia's .julia/packages/ directory. In particular, the edit function

edit(LineSearches.HagerZhang,())

is broken by the line info being wrong, it opens the editor at Parameters.jl

@mauro3
Copy link
Owner

mauro3 commented Feb 1, 2021

Yes, I'm semi aware of this. Thanks for reporting. Unfortunately, I don't think I will have time to look into this until end of February. I think the cause is probably:

function next(lns::Lines, nr)
for i=nr:length(lns.block.args)
if lns.block.args[i] isa LineNumberNode
continue
end
if ( lns.block.args[i] isa Symbol
|| lns.block.args[i] isa String # doc-string
|| !(lns.block.args[i].head==:line))
return lns.block.args[i], i+1
end
end
return -1
end

@mauro3 mauro3 linked a pull request Feb 25, 2021 that will close this issue
@mauro3
Copy link
Owner

mauro3 commented Feb 25, 2021

The line now points the top of the struct def. Is this good enough for the edit function. (Otherwise, I'm not sure what to do)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants