Skip to content

Commit

Permalink
Allow specialization in show_convert_error
Browse files Browse the repository at this point in the history
`arg_types_param` is known to be a `Core.SimpleVector`
  • Loading branch information
timholy committed Aug 13, 2021
1 parent 69be4a0 commit d72913c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,20 @@ function print_with_compare(io::IO, @nospecialize(a), @nospecialize(b), color::S
end
end

function show_convert_error(io::IO, ex::MethodError, @nospecialize(arg_types_param))
function show_convert_error(io::IO, ex::MethodError, arg_types_param)
# See #13033
T = striptype(ex.args[1])
if T === nothing
print(io, "First argument to `convert` must be a Type, got ", ex.args[1])
else
print_one_line = isa(T, DataType) && isa(arg_types_param[2], DataType) && T.name != arg_types_param[2].name
p2 = arg_types_param[2]
print_one_line = isa(T, DataType) && isa(p2, DataType) && T.name != p2.name
printstyled(io, "Cannot `convert` an object of type ")
print_one_line || printstyled(io, "\n ")
print_with_compare(io, arg_types_param[2], T, :light_green)
print_with_compare(io, p2, T, :light_green)
printstyled(io, " to an object of type ")
print_one_line || printstyled(io, "\n ")
print_with_compare(io, T, arg_types_param[2], :light_red)
print_with_compare(io, T, p2, :light_red)
end
end

Expand Down

0 comments on commit d72913c

Please sign in to comment.