Skip to content

Commit b44faa3

Browse files
authored
Fix #20108 fix #20111: method display errors (#20119)
* Fix #20108 fix #20111: method display errors * Update replutil.jl
1 parent ac9b2e7 commit b44faa3

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

base/methodshow.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ end
8787
function show(io::IO, m::Method; kwtype::Nullable{DataType}=Nullable{DataType}())
8888
tv, decls, file, line = arg_decl_parts(m)
8989
sig = unwrap_unionall(m.sig)
90-
ft = sig.parameters[1]
90+
ft = unwrap_unionall(sig.parameters[1])
9191
d1 = decls[1]
9292
if sig === Tuple
9393
print(io, m.name)

base/replutil.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ function show_method_candidates(io::IO, ex::MethodError, kwargs::Vector=Any[])
515515
# If the methods args is longer than input then the method
516516
# arguments is printed as not a match
517517
for (k, sigtype) in enumerate(sig[length(t_i)+1:end])
518+
sigtype = isvarargtype(sigtype) ? unwrap_unionall(sigtype) : sigtype
518519
if Base.isvarargtype(sigtype)
519520
sigstr = string(sigtype.parameters[1], "...")
520521
else

test/replutil.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,19 @@ let d = Dict(1 => 2, 3 => 45)
453453
end
454454
end
455455

456+
# Issue #20108
457+
let err, buf = IOBuffer()
458+
try Array() catch err end
459+
Base.show_method_candidates(buf,err)
460+
@test isa(err, MethodError)
461+
@test contains(String(buf), "Closest candidates are:")
462+
end
463+
464+
# Issue 20111
465+
let K20111(x) = y -> x, buf = IOBuffer()
466+
show(buf, methods(K20111(1)))
467+
@test contains(String(buf), " 1 method for generic function")
468+
end
456469

457470
# @macroexpand tests
458471
macro seven_dollar(ex)

0 commit comments

Comments
 (0)