Skip to content

Commit

Permalink
Fix JuliaLang#20108 fix JuliaLang#20111: method display errors (Julia…
Browse files Browse the repository at this point in the history
…Lang#20119)

* Fix JuliaLang#20108 fix JuliaLang#20111: method display errors

* Update replutil.jl
  • Loading branch information
ihnorton committed Jan 22, 2017
1 parent ac9b2e7 commit b44faa3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/methodshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ end
function show(io::IO, m::Method; kwtype::Nullable{DataType}=Nullable{DataType}())
tv, decls, file, line = arg_decl_parts(m)
sig = unwrap_unionall(m.sig)
ft = sig.parameters[1]
ft = unwrap_unionall(sig.parameters[1])
d1 = decls[1]
if sig === Tuple
print(io, m.name)
Expand Down
1 change: 1 addition & 0 deletions base/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ function show_method_candidates(io::IO, ex::MethodError, kwargs::Vector=Any[])
# If the methods args is longer than input then the method
# arguments is printed as not a match
for (k, sigtype) in enumerate(sig[length(t_i)+1:end])
sigtype = isvarargtype(sigtype) ? unwrap_unionall(sigtype) : sigtype
if Base.isvarargtype(sigtype)
sigstr = string(sigtype.parameters[1], "...")
else
Expand Down
13 changes: 13 additions & 0 deletions test/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,19 @@ let d = Dict(1 => 2, 3 => 45)
end
end

# Issue #20108
let err, buf = IOBuffer()
try Array() catch err end
Base.show_method_candidates(buf,err)
@test isa(err, MethodError)
@test contains(String(buf), "Closest candidates are:")
end

# Issue 20111
let K20111(x) = y -> x, buf = IOBuffer()
show(buf, methods(K20111(1)))
@test contains(String(buf), " 1 method for generic function")
end

# @macroexpand tests
macro seven_dollar(ex)
Expand Down

0 comments on commit b44faa3

Please sign in to comment.