Skip to content

Commit

Permalink
fix #40478: MethodError hint printed twice (#40479)
Browse files Browse the repository at this point in the history
#40304 accidentally registered
the error hint every time the error was printed.
  • Loading branch information
simeonschaub authored Apr 14, 2021
1 parent 2fed7c3 commit b10f9cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ function showerror(io::IO, ex::MethodError)
"\nYou can convert to a column vector with the vec() function.")
end
end
Experimental.register_error_hint(noncallable_number_hint_handler, MethodError)
Experimental.show_error_hints(io, ex, arg_types_param, kwargs)
try
show_method_candidates(io, ex, kwargs)
Expand Down Expand Up @@ -885,3 +884,5 @@ function noncallable_number_hint_handler(io, ex, arg_types, kwargs)
print(io, "?")
end
end

Experimental.register_error_hint(noncallable_number_hint_handler, MethodError)
5 changes: 4 additions & 1 deletion test/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,10 @@ struct ANumber <: Number end
let err_str
err_str = @except_str ANumber()(3 + 4) MethodError
@test occursin("objects of type $(curmod_prefix)ANumber are not callable", err_str)
@test occursin("Maybe you forgot to use an operator such as *, ^, %, / etc. ?", err_str)
@test count(==("Maybe you forgot to use an operator such as *, ^, %, / etc. ?"), split(err_str, '\n')) == 1
# issue 40478
err_str = @except_str ANumber()(3 + 4) MethodError
@test count(==("Maybe you forgot to use an operator such as *, ^, %, / etc. ?"), split(err_str, '\n')) == 1
end

# Execute backtrace once before checking formatting, see #38858
Expand Down

0 comments on commit b10f9cf

Please sign in to comment.