Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warn about usage of applicable and hasmethod #51260

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1882,6 +1882,14 @@ Determine whether the given generic function has a method applicable to the give

See also [`hasmethod`](@ref).

!!! warning
It is not guaranteed that the function `f` will provide the expected return
or will not throw exceptions if `applicable` returns `true`. For example,
one function can define a general method like `f(x::Any) = error("Type not
supported")` to catch unsupported types. In this case, `applicable` can
return `true`, but an error will be thrown when calling `f` with the
selected arguments.

# Examples
```jldoctest
julia> function f(x, y)
Expand Down
8 changes: 8 additions & 0 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1902,6 +1902,14 @@ the provided names must be a subset of the method's keyword arguments.

See also [`applicable`](@ref).

!!! warning
It is not guaranteed that the function `f` will provide the expected return
or will not throw exceptions if `hasmethod` returns `true`. For example,
one function can define a general method like `f(x::Any) = error("Type not
supported")` to catch unsupported types. In this case, `hasmethod` can
return `true`, but an error will be thrown when calling `f` with the
selected arguments.

!!! compat "Julia 1.2"
Providing keyword argument names requires Julia 1.2 or later.

Expand Down