Skip to content

Commit

Permalink
Pass through world age for kwargs MethodError
Browse files Browse the repository at this point in the history
Fixes #50200
  • Loading branch information
Keno committed Jun 16, 2023
1 parent 1200995 commit fe5f5f4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function showerror(io::IO, ex::MethodError)
ft = typeof(f)
arg_types_param = arg_types_param[3:end]
kwargs = pairs(ex.args[1])
ex = MethodError(f, ex.args[3:end::Int])
ex = MethodError(f, ex.args[3:end::Int], ex.world)
end
name = ft.name.mt.name
if f === Base.convert && length(arg_types_param) == 2 && !is_arg_types
Expand Down
27 changes: 26 additions & 1 deletion test/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ let
end
end

@testset "show for manually thrown MethodError" begin
@testset "show for MethodError with world age issue" begin
global f21006

f21006() = nothing
Expand Down Expand Up @@ -620,6 +620,31 @@ end
end
end

# Issue #50200
using Base.Experimental: @opaque
@testset "show for MethodError with world age issue (kwarg)" begin
test_no_error(f) = @test f() === nothing
function test_worldage_error(f)
ex = try; f(); error("Should not have been reached") catch ex; ex; end
@test occursin("The applicable method may be too new", sprint(Base.showerror, ex))
end

global callback50200

# First the no-kwargs version
callback50200 = (args...)->nothing
f = @opaque ()->callback50200()
test_no_error(f)
callback50200 = (args...)->nothing
test_worldage_error(f)

callback50200 = (args...; kwargs...)->nothing
f = @opaque ()->callback50200(;a=1)
test_no_error(f)
callback50200 = (args...; kwargs...)->nothing
test_worldage_error(f)
end

# Custom hints
struct HasNoOne end
function recommend_oneunit(io, ex, arg_types, kwargs)
Expand Down

0 comments on commit fe5f5f4

Please sign in to comment.