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 numbers off by one #247

Open
goerz opened this issue Feb 2, 2018 · 1 comment
Open

Line numbers off by one #247

goerz opened this issue Feb 2, 2018 · 1 comment

Comments

@goerz
Copy link

goerz commented Feb 2, 2018

The line numbers reported by the linter consistenly seem off by one, For example, when I do

julia> lintfile("./run_single_node.jl")

it reports things like

./run_single_node.jl:230 E321 new_basis: use of undeclared symbol

when new_basis is in fact used in line 229. The same is true for all other messages.

Actually, I also don't understand what Lint is complaining about in regards to new_basis, as it is an argument to the funtion that contains line 229:

"""
Pad the given `state` defined on `basis` with zeroes in order to fit on
`new_basis`

The `state` is assumed to be a concatenation of `pdim` classical paramters,
followed by `n_hilbert` entries giving the complex amplitude for each basis
state in `basis`. The output will contain the first `pdim` entries unchanged.
"""
function resize_state(state::Array, basis::Basis, new_basis::Basis):: Array
    n_hilbert = prod(basis.dims)
    new_n_hilbert = prod(new_basis.dims)   # this is line 229
    pdim = length(state) - n_hilbert
    @assert length(new_basis.dims) == length(basis.dims)
    @assert new_basis.dims >= basis.dims
    new_state = zeros(Complex128, pdim + new_n_hilbert)
    new_state[1:pdim] = state[1:pdim]
    j = 0
    for (i, etuple) in enumerate(basis.e)
    j += 1
    new_etuple = new_basis.e[j]
    while new_etuple != etuple
        j += 1
        new_etuple = new_basis.e[j]
    end
    new_state[pdim + j] = state[pdim + i]
    end
    return new_state
end

I wonder if it's being thrown off by the docstring, because it also says

run_single_node.jl:219 E131 resize_state(state::Array, basis::Basis, new_basis::Basis): Lint does not understand argument #1

about the line that starts the docstring.

@TotalVerb
Copy link
Collaborator

I think Lint doesn't understand return type annotations. I had a (slightly stale) PR addressing that, but it's not quite done.

As for the lines, I think that might be partially a limitation of how we are parsing the code to lint. Eventually we want to migrate to a multi-layer linter starting at the CST layer, but there is a lot of work to be done to get there, and recently this package has gone somewhat undermaintained.

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

No branches or pull requests

2 participants