Skip to content

Commit

Permalink
fix method error printing for missing (JuliaLang#35315)
Browse files Browse the repository at this point in the history
fix method error printing for missing
  • Loading branch information
KristofferC authored and ravibitsgoa committed Apr 6, 2020
1 parent febeb9b commit f261976
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ function showerror(io::IO, ex::MethodError)
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
if f === Base.convert && length(arg_types_param) == 2 && !is_arg_types
f_is_function = true
show_convert_error(io, ex, arg_types_param)
elseif isempty(methods(f)) && isa(f, DataType) && f.abstract
Expand Down Expand Up @@ -351,7 +351,7 @@ function showerror(io::IO, ex::MethodError)
print(io, ")")
end
# catch the two common cases of element-wise addition and subtraction
if f in (Base.:+, Base.:-) && length(arg_types_param) == 2
if (f === Base.:+ || f === Base.:-) && length(arg_types_param) == 2
# we need one array of numbers and one number, in any order
if any(x -> x <: AbstractArray{<:Number}, arg_types_param) &&
any(x -> x <: Number, arg_types_param)
Expand Down
5 changes: 5 additions & 0 deletions test/missing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -527,3 +527,8 @@ mutable struct Obj; x; end
@test ismissing(wref[1] == missing)
@test ismissing(missing == wref[1])
end

@testset "showerror missing function" begin
me = try missing(1) catch e e end
@test sprint(showerror, me) == "MethodError: objects of type Missing are not callable"
end

0 comments on commit f261976

Please sign in to comment.