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
2 changes: 1 addition & 1 deletion src/CodeTracking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ 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
if isexpr(ex, :call) && length(ex.args) > 1 && first(ex.args) == :eval && isexpr(last(ex.args), :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
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ isdefined(Main, :Revise) ? Main.Revise.includet("script.jl") : include("script.j
src, line = definition(String, m)
@test occursin("NamedTuple{names, T}(args::T) where {names, T <: Tuple}", src)
@test line == m.line

# Parsed result gives a symbol instead of expression
m = @which symbol_function(1)
@test_nowarn definition(String, m)
end

@testset "With Revise" begin
Expand Down
5 changes: 5 additions & 0 deletions test/script.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,8 @@ end
struct Invert end
(::Invert)(v::AbstractVector{Bool}) = (!).(v)
(::Type{T})(itr) where {T<:Invert} = [!x for x in itr]

# USERID gets parsed into a Symbol
struct symbol_struct2
USERID
end; '\n' ;symbol_function(x) = x