Skip to content

Commit

Permalink
Fix comments from reviewer
Browse files Browse the repository at this point in the history
  • Loading branch information
dhoegh committed Jun 26, 2016
1 parent 673826b commit c353489
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions base/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function showerror(io::IO, ex::MethodError)
name = ft.name.mt.name
arg_types_param = arg_types_param[3:end]
temp = ex.args[1]
kwargs = [(temp[i*2-1], temp[i*2]) for i in 1:(length(temp) ÷ 2)]
kwargs = Any[(temp[i*2-1], temp[i*2]) for i in 1:(length(temp) ÷ 2)]
ex = MethodError(f, ex.args[3:end])
end
if f == Base.convert && length(arg_types_param) == 2 && !is_arg_types
Expand Down Expand Up @@ -163,7 +163,8 @@ function showerror(io::IO, ex::MethodError)
if !isempty(kwargs)
print(io, "; ")
for (i ,(k, v)) in enumerate(kwargs)
print(io, k, "=", v)
print(io, k, "=")
show(IOContext(io, :limit=>true), v)
i == length(kwargs) || print(io, ", ")
end
end
Expand Down Expand Up @@ -239,7 +240,7 @@ function showerror_nostdio(err, msg::AbstractString)
ccall(:jl_printf, Cint, (Ptr{Void},Cstring), stderr_stream, "\n")
end

function show_method_candidates(io::IO, ex::MethodError, kwargs=Tuple{Symbol, Any}[])
function show_method_candidates(io::IO, ex::MethodError, kwargs::Vector=Any[])
is_arg_types = isa(ex.args, DataType)
arg_types = is_arg_types ? ex.args : typesof(ex.args...)
arg_types_param = Any[arg_types.parameters...]
Expand Down
4 changes: 4 additions & 0 deletions test/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ method_c7(a, b; kargs...) = a
Base.show_method_candidates(buf, MethodError(method_c7, (1, 1)), [(:x, 1), (:y, 2)])
test_have_color(buf, "\e[0m\nClosest candidates are:\n method_c7(::Any, ::Any; kargs...)\e[0m",
"\nClosest candidates are:\n method_c7(::Any, ::Any; kargs...)")
method_c8(a, b; y=1, w=1) = a
Base.show_method_candidates(buf, MethodError(method_c8, (1, 1)), [(:x, 1), (:y, 2), (:z, 1), (:w, 1)])
test_have_color(buf, "\e[0m\nClosest candidates are:\n method_c8(::Any, ::Any; y, w)\e[1m\e[31m got an unsupported keyword argument \"x\", \"z\"\e[0m\e[0m",
"\nClosest candidates are:\n method_c8(::Any, ::Any; y, w) got an unsupported keyword argument \"x\", \"z\"")

addConstraint_15639(c::Int32) = c
addConstraint_15639(c::Int64; uncset=nothing) = addConstraint_15639(Int32(c), uncset=uncset)
Expand Down

0 comments on commit c353489

Please sign in to comment.