From 49207d96d652dc73a3be7fc6d171f63eb653d21b Mon Sep 17 00:00:00 2001 From: dhoegh Date: Fri, 30 Jan 2015 11:26:32 +0100 Subject: [PATCH] Fix so the `show_method_candidates` do not fail for method with 0 args. --- base/replutil.jl | 2 +- test/replutil.jl | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/base/replutil.jl b/base/replutil.jl index c762a6da63466..820e3c82ef332 100644 --- a/base/replutil.jl +++ b/base/replutil.jl @@ -212,7 +212,7 @@ function show_method_candidates(io::IO, ex::MethodError) print(buf, "::$(method.sig[i])") end end - if length(t_i) > length(method.sig) && Base.isvarargtype(method.sig[end]) + if length(t_i) > length(method.sig) && !isempty(method.sig) && Base.isvarargtype(method.sig[end]) # It ensures that methods like f(a::AbstractString...) gets the correct # number of right_matches for t in typeof(ex.args)[length(method.sig):end] diff --git a/test/replutil.jl b/test/replutil.jl index ba4dcc3e04fe0..ad17a7885cc25 100644 --- a/test/replutil.jl +++ b/test/replutil.jl @@ -46,4 +46,8 @@ method_c3(x::Float64, y::Float64) = true Base.show_method_candidates(buf, Base.MethodError(method_c3,(1.,))) color = "\e[0m\nClosest candidates are:\n method_c3(::Float64, \e[1m\e[31m::Float64\e[0m)\n\e[0m" no_color = no_color = "\nClosest candidates are:\n method_c3(::Float64, !Matched::Float64)\n" -test_have_color(buf, color, no_color) \ No newline at end of file +test_have_color(buf, color, no_color) + +# Test for the method error in issue #8651 +Base.show_method_candidates(buf, MethodError(readline,(ASCIIString,))) +test_have_color(buf, "", "") \ No newline at end of file