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
6 changes: 6 additions & 0 deletions src/CodeTracking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ function definition(::Type{String}, method::Method)
lineindex = lastindex(linestarts)
linestop = max(0, lineindex - 20)
while !is_func_expr(ex, method) && lineindex > linestop
if ex.head == :call && length(ex.args) > 1 && first(ex.args) == :eval && last(ex.args).head == :quote && length(last(ex.args).args) > 0
actual_ex = first(last(ex.args).args)
if is_func_expr(actual_ex, method)
return clean_source(string(actual_ex)), line
end
end
istart = linestarts[lineindex]
try
ex, iend = Meta.parse(src, istart)
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ isdefined(Main, :Revise) ? Main.Revise.includet("script.jl") : include("script.j
d = IdDict{Union{String,Symbol},Union{Function,Vector{Function}}}()
CodeTracking.invoked_setindex!(d, sin, "sin")
@test CodeTracking.invoked_get!(Vector{Function}, d, :cos) isa Vector{Function}

# Issue 115, Cthulhu issue 474
m = @which NamedTuple{(),Tuple{}}(())
src, line = definition(String, m)
@test occursin("NamedTuple{names, T}(args::T) where {names, T <: Tuple}", src)
@test line == m.line
end

@testset "With Revise" begin
Expand Down