diff --git a/Project.toml b/Project.toml index 10941e4..ba6a932 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "CodeTracking" uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" authors = ["Tim Holy "] -version = "2.0.0" +version = "2.0.1" [deps] InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" diff --git a/src/CodeTracking.jl b/src/CodeTracking.jl index 2dda17b..a67b50a 100644 --- a/src/CodeTracking.jl +++ b/src/CodeTracking.jl @@ -229,6 +229,7 @@ function definition(::Type{String}, method::Method) p = Base.unwrap_unionall(method.sig).parameters for i = 2:length(p) T = p[i] + isa(T, Core.TypeofVararg) && break # it's not our target, and there are no more arguments after this if T <: Function mstring = string(nameof(T)) if startswith(mstring, '#') @@ -237,7 +238,7 @@ function definition(::Type{String}, method::Method) end end end - methodname == :kwcall && error("could not identify method name in `Core.kwcall`") + methodname == :kwcall && error("could not identify method name in `Core.kwcall` (signature: $(method.sig))") end file, line = whereis(method) line == 0 && return nothing diff --git a/test/runtests.jl b/test/runtests.jl index b34820b..66278c7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -292,6 +292,11 @@ isdefined(Main, :Revise) ? Main.Revise.includet("script.jl") : include("script.j src, line = definition(String, m) @test occursin("::Type{P}", src) @test line == 148 + + # Graceful handling of `kwcall` definition lookup failure + m = @which Core.kwcall(NamedTuple(), Union{}) + @test_throws "could not identify method name in `Core.kwcall`" definition(String, m) + @test_throws "signature: Tuple{typeof(Core.kwcall), Any, Type{Union{}}, Vararg{Any}}" definition(String, m) end @testset "With Revise" begin