diff --git a/base/error.jl b/base/error.jl index 37ceb39253e38..fc294b3cb3eb0 100644 --- a/base/error.jl +++ b/base/error.jl @@ -162,7 +162,7 @@ end ## keyword arg lowering generates calls to this ## function kwerr(kw, args::Vararg{Any,N}) where {N} @noinline - throw(MethodError(Core.kwcall, (kw, args...))) + throw(MethodError(Core.kwcall, (kw, args...), tls_world_age())) end ## system error handling ## diff --git a/base/errorshow.jl b/base/errorshow.jl index 1e6a6faaae5df..abc8083f38266 100644 --- a/base/errorshow.jl +++ b/base/errorshow.jl @@ -327,10 +327,11 @@ function showerror(io::IO, ex::MethodError) end end if ex.world == typemax(UInt) || hasmethod(f, arg_types, world=ex.world) + if !isempty(kwargs) + print(io, "\nThis method does not support all of the given keyword arguments (and may not support any).") + end if ex.world == typemax(UInt) || isempty(kwargs) print(io, "\nThis error has been manually thrown, explicitly, so the method may exist but be intentionally marked as unimplemented.") - else - print(io, "\nThis method may not support any keyword arguments.") end elseif hasmethod(f, arg_types) && !hasmethod(f, arg_types, world=ex.world) curworld = get_world_counter() diff --git a/test/errorshow.jl b/test/errorshow.jl index d03de54aab496..5d0640601b398 100644 --- a/test/errorshow.jl +++ b/test/errorshow.jl @@ -671,7 +671,7 @@ end str = sprint(Base.showerror, MethodError(Core.kwcall, ((; a=3.0), +, 1.0, 2.0), Base.get_world_counter())) @test startswith(str, "MethodError: no method matching +(::Float64, ::Float64; a::Float64)") - @test occursin("This method may not support any keyword arguments", str) + @test occursin("This method does not support all of the given keyword arguments", str) @test_throws "MethodError: no method matching kwcall()" Core.kwcall() end