From 6840e75d3aa87d07d82a0adb16b7944c29cc6ccc Mon Sep 17 00:00:00 2001 From: Isaiah Norton Date: Wed, 18 Jan 2017 23:28:02 -0500 Subject: [PATCH] Fix #20108 fix #20111: method display errors --- base/methodshow.jl | 2 +- base/replutil.jl | 1 + test/replutil.jl | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/base/methodshow.jl b/base/methodshow.jl index f9bf78f514907..269a1dfeb89cc 100644 --- a/base/methodshow.jl +++ b/base/methodshow.jl @@ -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) diff --git a/base/replutil.jl b/base/replutil.jl index f839f597164ea..d15f24ae58b9e 100644 --- a/base/replutil.jl +++ b/base/replutil.jl @@ -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 diff --git a/test/replutil.jl b/test/replutil.jl index ed4489a923bac..e25ce38fb0072 100644 --- a/test/replutil.jl +++ b/test/replutil.jl @@ -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)