Skip to content

method_exists inconsistent with parameterised functions #8959

@mauro3

Description

@mauro3

I found the following inconsistence in method_exists:

# without type parameters, all good:
f(x,y) = 1
@assert method_exists(f, (None, None))
@assert method_exists(f, (Int, None))
@assert method_exists(f, (Int, Int))
@assert method_exists(f, (None, Int))

# with two type parameters, all good:
h{T,K}(x::T,y::K) = 1
@assert method_exists(h, (None, None))
@assert method_exists(h, (Int, None))
@assert method_exists(h, (Int, Int))
@assert method_exists(h, (None, Int))

# with one type parameter:
g{T}(x::T,y) = 1
@assert method_exists(g, (None, None))
# ERROR: assertion failed: method_exists(g,(None,None))
#  in error at error.jl:21
@assert method_exists(g, (Int, None))
# ERROR: assertion failed: method_exists(g,(Int,None))
#  in error at error.jl:21
@assert method_exists(g, (Int, Int))
@assert method_exists(g, (None, Int))

I think the last example should work like the second one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    types and dispatchTypes, subtyping and method dispatch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions