Skip to content

Commit

Permalink
fix printing of method errors when no kwarg sorter matches (#25658)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Jan 21, 2018
1 parent e6d4245 commit 239036d
Show file tree
Hide file tree
Showing 3 changed files with 9 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 @@ -328,7 +328,7 @@ function showerror(io::IO, ex::MethodError)
ft = typeof(f)
name = ft.name.mt.name
arg_types_param = arg_types_param[3:end]
kwargs = ex.args[1]
kwargs = pairs(ex.args[1])
ex = MethodError(f, ex.args[3:end])
end
if f == Base.convert && length(arg_types_param) == 2 && !is_arg_types
Expand Down
2 changes: 1 addition & 1 deletion src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@
,@(if (null? restkw)
`((if (call (top isempty) ,rkw)
(null)
(call (top kwerr) (call (top pairs) ,kw) ,@(map arg-name pargl)
(call (top kwerr) ,kw ,@(map arg-name pargl)
,@(if (null? vararg) '()
(list `(... ,(arg-name (car vararg))))))))
'())
Expand Down
7 changes: 7 additions & 0 deletions test/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ method_c8(a, b; y=1, w=1) = a
Base.show_method_candidates(buf, MethodError(method_c8, (1, 1)), pairs((x = 1, y = 2, z = 1, w = 1)))
@test String(take!(buf)) == "\nClosest candidates are:\n method_c8(::Any, ::Any; y, w)$cfile$c8line got unsupported keyword arguments \"x\", \"z\""

let no_kwsorter_match, e
no_kwsorter_match() = 0
no_kwsorter_match(a;y=1) = y
e = try no_kwsorter_match(y=1) catch ex; ex; end
@test contains(sprint(showerror, e), r"no method matching.+\(; y=1\)")
end

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

0 comments on commit 239036d

Please sign in to comment.