Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/CodeTracking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ function definition(::Type{String}, method::Method)
istart = 1
for _ = 1:line-1
push!(linestarts, istart)
istart = findnext(eol, src, istart) + 1
istart = findnext(eol, src, istart)
istart === nothing && return nothing # unexpected EOF
istart += 1
end
push!(linestarts, istart)
# Parse the function definition (hoping that we've found the right location to start)
Expand Down
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ isdefined(Main, :Revise) ? Main.Revise.includet("script.jl") : include("script.j
# Parsed result gives a symbol instead of expression
m = @which symbol_function(1)
@test_nowarn definition(String, m)

# #124
if !isdefined(Main, :Revise)
@test definition(String, only(methods(wrongline))) === nothing
end
end

@testset "With Revise" begin
Expand Down
3 changes: 3 additions & 0 deletions test/script.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,6 @@ let argnames = :args
end
end)
end

wrongline() = 1 # for use testing #124
only(methods(wrongline)).line = 9999 # unclear how it happened in the wild, but this at least catches the problem