Skip to content

Commit

Permalink
Merge pull request #9968 from dhoegh/#8651
Browse files Browse the repository at this point in the history
Fix `show_method_candidates` so it do not fail for methods with zero args.
  • Loading branch information
ivarne committed Jan 30, 2015
2 parents e41a507 + 49207d9 commit 61d3ece
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 5 additions & 1 deletion test/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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, "", "")

0 comments on commit 61d3ece

Please sign in to comment.