Skip to content

Commit

Permalink
fix keyword values being shown in MethodError (#45255)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC authored May 12, 2022
1 parent cd51a39 commit 3653d3d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ function showerror(io::IO, ex::MethodError)
if !isempty(kwargs)
print(io, "; ")
for (i, (k, v)) in enumerate(kwargs)
print(io, k, "=")
show(IOContext(io, :limit => true), v)
print(io, k, "::", typeof(v))
i == length(kwargs)::Int || print(io, ", ")
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ 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 occursin(r"no method matching.+\(; y=1\)", sprint(showerror, e))
@test occursin(Regex("no method matching.+\\(; y::$(Int)\\)"), sprint(showerror, e))
end

ac15639line = @__LINE__
Expand Down Expand Up @@ -623,7 +623,7 @@ let err_str
@test occursin(r"MethodError: no method matching one\(::.*HasNoOne\)", err_str)
@test occursin("HasNoOne does not support `one`; did you mean `oneunit`?", err_str)
err_str = @except_str one(HasNoOne(); value=2) MethodError
@test occursin(r"MethodError: no method matching one\(::.*HasNoOne; value=2\)", err_str)
@test occursin(Regex("MethodError: no method matching one\\(::.*HasNoOne; value::$(Int)\\)"), err_str)
@test occursin("`one` doesn't take keyword arguments, that would be silly", err_str)
end
pop!(Base.Experimental._hint_handlers[MethodError]) # order is undefined, don't copy this
Expand Down

0 comments on commit 3653d3d

Please sign in to comment.