diff --git a/src/CodeTracking.jl b/src/CodeTracking.jl index 23d4982..6fc8991 100644 --- a/src/CodeTracking.jl +++ b/src/CodeTracking.jl @@ -204,16 +204,12 @@ function definition(::Type{String}, method::Method) end # The function declaration was presumably on a previous line lineindex = lastindex(linestarts) - local istart_noerr while !isfuncexpr(ex) && lineindex > 0 istart = linestarts[lineindex] try ex, iend = Meta.parse(src, istart) catch - istart = istart_noerr - break end - istart_noerr = istart lineindex -= 1 line -= 1 end diff --git a/test/runtests.jl b/test/runtests.jl index 1d3b8ff..495d991 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -39,6 +39,11 @@ isdefined(Main, :Revise) ? includet("script.jl") : include("script.jl") @test startswith(src, "@noinline") @test line == 7 + m = first(methods(multilinesig)) + src, line = definition(String, m) + @test startswith(src, "@inline") + @test line == 16 + info = CodeTracking.PkgFiles(Base.PkgId(CodeTracking)) @test Base.PkgId(info) === info.id @test CodeTracking.basedir(info) == dirname(@__DIR__) diff --git a/test/script.jl b/test/script.jl index 59a1c87..c460fea 100644 --- a/test/script.jl +++ b/test/script.jl @@ -12,3 +12,9 @@ end call_throws() = inlined() f2(x, y) = x + y + +@inline function multilinesig(x::Int, + y::String) + z = x + 1 + return z +end