From d5c3e01b844e34099fb160ceb956ad50587c8056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller-Widmann?= Date: Mon, 21 Sep 2026 13:26:44 +0200 Subject: [PATCH 1/3] Fix extension name in the `Test` error hint `Base.get_extension` returns `nothing` for an unknown extension name, so querying `:InverseFunctionsTest` instead of `:InverseFunctionsTestExt` left the guard permanently true: "Did you forget to load Test?" was appended to every `test_inverse` `MethodError`, including those raised when `Test` is loaded and the extension method exists. Co-Authored-By: Claude Opus 5 (1M context) --- src/InverseFunctions.jl | 2 +- test/test_inverse.jl | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/InverseFunctions.jl b/src/InverseFunctions.jl index 4cffde1..0728ef2 100644 --- a/src/InverseFunctions.jl +++ b/src/InverseFunctions.jl @@ -38,7 +38,7 @@ if isdefined(Base, :get_extension) && isdefined(Base.Experimental, :register_err function __init__() Base.Experimental.register_error_hint(MethodError) do io, exc, _, _ if exc.f === test_inverse && - (Base.get_extension(InverseFunctions, :InverseFunctionsTest) === nothing) + (Base.get_extension(InverseFunctions, :InverseFunctionsTestExt) === nothing) print(io, "\nDid you forget to load Test?") end end diff --git a/test/test_inverse.jl b/test/test_inverse.jl index 79cf725..6c01288 100644 --- a/test/test_inverse.jl +++ b/test/test_inverse.jl @@ -43,6 +43,25 @@ end InverseFunctions.test_inverse(inverse, log, compare = ===) end +@testset "test_inverse" begin + err = try + InverseFunctions.test_inverse(identity) + catch e + e + end + @test err isa MethodError + @test !occursin("Did you forget to load Test?", sprint(showerror, err)) + + # Test can't be unloaded, so the hint itself is checked in a subprocess + if isdefined(Base, :get_extension) + script = "using InverseFunctions; InverseFunctions.test_inverse(identity, 1)" + cmd = `$(Base.julia_cmd()) --startup-file=no --project=$(Base.active_project()) -e $script` + output = IOBuffer() + run(pipeline(ignorestatus(cmd); stdout=output, stderr=output)) + @test occursin("Did you forget to load Test?", String(take!(output))) + end +end + @testset "maths" begin InverseFunctions.test_inverse(!, false) From c70bfd3b4f3555ef7fed2bb807160729fece119b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller-Widmann?= Date: Thu, 15 Oct 2026 16:17:14 +0200 Subject: [PATCH 2/3] Test that `test_inverse` has no method without `Test` With the error hint kept, `test_inverse` only gains a method when `InverseFunctionsTestExt` is loaded, so `hasmethod` tells downstream code whether `test_inverse` is usable. Co-Authored-By: Claude Opus 5.5 --- test/test_inverse.jl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/test_inverse.jl b/test/test_inverse.jl index 6c01288..caf0924 100644 --- a/test/test_inverse.jl +++ b/test/test_inverse.jl @@ -44,6 +44,8 @@ end end @testset "test_inverse" begin + @test hasmethod(InverseFunctions.test_inverse, Tuple{Any,Any}) + err = try InverseFunctions.test_inverse(identity) catch e @@ -52,13 +54,19 @@ end @test err isa MethodError @test !occursin("Did you forget to load Test?", sprint(showerror, err)) - # Test can't be unloaded, so the hint itself is checked in a subprocess + # Test can't be unloaded, so the behaviour without it is checked in a subprocess if isdefined(Base, :get_extension) - script = "using InverseFunctions; InverseFunctions.test_inverse(identity, 1)" + script = """ + using InverseFunctions + println("hasmethod: ", hasmethod(InverseFunctions.test_inverse, Tuple{Any,Any})) + InverseFunctions.test_inverse(identity, 1) + """ cmd = `$(Base.julia_cmd()) --startup-file=no --project=$(Base.active_project()) -e $script` output = IOBuffer() run(pipeline(ignorestatus(cmd); stdout=output, stderr=output)) - @test occursin("Did you forget to load Test?", String(take!(output))) + str = String(take!(output)) + @test occursin("hasmethod: false", str) + @test occursin("Did you forget to load Test?", str) end end From aabdd9b023f329216318130022e4d294fe5a7d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller-Widmann?= Date: Thu, 15 Oct 2026 16:17:14 +0200 Subject: [PATCH 3/3] Bump version to 0.1.18 Co-Authored-By: Claude Opus 5.5 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index b6acb6f..bd50f06 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "InverseFunctions" uuid = "3587e190-3f89-42d0-90ee-14403ec27112" -version = "0.1.17" +version = "0.1.18" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"