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 Number Accuracy #18273

Closed
JaredCrean2 opened this issue Aug 29, 2016 · 8 comments
Closed

Line Number Accuracy #18273

JaredCrean2 opened this issue Aug 29, 2016 · 8 comments

Comments

@JaredCrean2
Copy link
Contributor

Line numbers are off by a few lines, causing confusion. Here is a minimal standalone example:

module C

  global const PETSC_DECIDE = -1
  typealias PetscInt Int64
  MATMPIAIJ = "matmpiaij"
  MatType = Symbol


end  # end module C

module MPI
  typealias Comm Cint
  COMM_WORLD = Cint(42)
end

module PETSc

using MPI
using C

function Mat{T}(::Type{T}, mtype::C.MatType=C.MATSEQAIJ; comm::MPI.Comm=MPI.COMM_WORLD)

  println("I found the other half of the problem")
end


function Mat{T}(::Type{T}, m::Integer=C.PETSC_DECIDE, n::Integer=C.PETSC_DECIDE;
                mlocal::Integer=C.PETSC_DECIDE, nlocal::Integer=C.PETSC_DECIDE,
                bs=1, nz::Integer=0, nnz::AbstractVector=PetscInt[],
                onz::Integer=0, onnz::AbstractVector=PetscInt[],
                comm::MPI.Comm=MPI.COMM_WORLD,
                mtype::Symbol=C.MATMPIAIJ)


  println("I finally found the problem")

  return nothing
end

end  # end module PETSc

using PETSc

gives output:

WARNING: Method definition Mat(Type{#T<:Any}) in module PETSc at /home/jared/.julia/v0.4/PETSc_current/src/tmp.jl:24 overwritten at /home/jared/.julia/v0.4/PETSc_current/src/tmp.jl:36.
WARNING: Method definition #Mat(Array{Any, 1}, PETSc.#Mat, Type{#T<:Any}) in module PETSc overwritten.

lines 24 and 36 contain the println statements, rather than the function declarations.

@JaredCrean2
Copy link
Contributor Author

I should add this occurred with both 0.5-rc1 and the more recent

Julia Version 0.6.0-dev.201
Commit e4b5233* (2016-08-13 16:10 UTC)
Platform Info:
  System: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7 CPU       Q 820  @ 1.73GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Nehalem)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, nehalem)

@yuyichao
Copy link
Contributor

Note that fixing this should be careful to not break coverage line number.

@JeffBezanson
Copy link
Sponsor Member

This has come up before --- we only keep the line number for the first line of code in the function, since that's the one we need for coverage and error reporting. It still uniquely and correctly identifies the function so I don't consider this a significant problem.

@JaredCrean2
Copy link
Contributor Author

The line number of the first statement does uniquely identify the function, but incorrectly identifies the error. For example, in the original code the second function was calling the first function on the first line, so it appeared calling the function was overwriting it.

@yuyichao
Copy link
Contributor

The warning in this case isn't really confusing since it's pretty clear where the override is. It could be more confusing if the first line is a function definition though.

It still uniquely and correctly identifies the function

Not actually true when there's nested function definition. It is possible to define multiple functions in one line but the currently lineno handling does cause some false positive.

@evanfields
Copy link

evanfields commented Aug 30, 2016

Line numbers are sometimes off by more than a few lines. Right now I'm working on a script (180 lines) but when I include the script, I get a method error referencing an expression starting on line 480. If I can create a small example I'll update this comment. [Edit: see below]

julia> include("src\\simulation_based_optimization\\so.jl")
ERROR: LoadError: UndefVarError: SOPoinType not defined
 in include_from_node1(::String) at .\loading.jl:426
while loading C:\Users\ejfie\zipcarpodmodel\src\simulation_based_optimization\so.jl, in expression starting on line 480

Maybe that 480 refers to something in loading.jl in which case it's an issue of deceptive error messages, not line accuracy.

Edit: This is on 0.5.0-rc3. @yuyichao Sounds like this issue is already well known, but let me know if you want me to open an issue.

Edit2: Here's a minimal example. File linenumber.jl:

"With this comment the line number given is 480; without the line number given is 1."
type TypeA
    x::TypeB
end

type TypeB
end

Running it:

julia> include("C:\\Users\\ejfie\\Desktop\\linenumber.jl")
ERROR: LoadError: UndefVarError: TypeB not defined
 in include_from_node1(::String) at .\loading.jl:426
while loading C:\Users\ejfie\Desktop\linenumber.jl, in expression starting on line 480

@yuyichao
Copy link
Contributor

@evanfields this is a different issue. I mostly see this happen when there's macros that messes up line number info. Please also include the exact version of julia you are using when you report the issue.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jul 10, 2020

Confirmed fixed by #35138

@vtjnash vtjnash closed this as completed Jul 10, 2020
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

5 participants