From b4c4a9b79d3fe036be4ca08743ac7897c942cf42 Mon Sep 17 00:00:00 2001 From: serenity4 Date: Fri, 19 Sep 2025 14:10:38 +0000 Subject: [PATCH 1/3] Improve handling of kwcall definition failure --- src/CodeTracking.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From 11b68845610be6469e9ee659f87d6ad23c739f73 Mon Sep 17 00:00:00 2001 From: serenity4 Date: Fri, 19 Sep 2025 14:11:17 +0000 Subject: [PATCH 2/3] Bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From 5679ae96cd1009b89dc4bf507c26f530ee6675ae Mon Sep 17 00:00:00 2001 From: serenity4 Date: Fri, 19 Sep 2025 15:36:47 +0000 Subject: [PATCH 3/3] Add test for `kwcall` handling failure --- test/runtests.jl | 5 +++++ 1 file changed, 5 insertions(+) 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