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

method_exists inconsistent with parameterised functions #8959

Closed
mauro3 opened this issue Nov 10, 2014 · 2 comments
Closed

method_exists inconsistent with parameterised functions #8959

mauro3 opened this issue Nov 10, 2014 · 2 comments
Labels
types and dispatch Types, subtyping and method dispatch

Comments

@mauro3
Copy link
Contributor

mauro3 commented Nov 10, 2014

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.

mauro3 added a commit to mauro3/Traits.jl that referenced this issue Nov 10, 2014
@ihnorton ihnorton added the types and dispatch Types, subtyping and method dispatch label Jan 30, 2015
@mauro3
Copy link
Contributor Author

mauro3 commented Apr 7, 2015

Some more datapoints:

julia> @assert method_exists(f, (Any,Any))

julia> @assert method_exists(h, (Any,Any))
ERROR: AssertionError: method_exists(h,(Any,Any))

julia> @assert method_exists(g, (Any,Any))
ERROR: AssertionError: method_exists(g,(Any,Any))

mauro3 added a commit to mauro3/Traits.jl that referenced this issue Apr 10, 2015
These two bugs do not matter anymore as the new tests do not rely on method_exists:
method_exists_bug1 = false # see JuliaLang/julia#8959
method_exists_bug2 = false # see JuliaLang/julia#9043 and #2
mauro3 added a commit to mauro3/Traits.jl that referenced this issue Apr 14, 2015
These two bugs do not matter anymore as the new tests do not rely on method_exists:
method_exists_bug1 = false # see JuliaLang/julia#8959
method_exists_bug2 = false # see JuliaLang/julia#9043 and #2
@mauro3
Copy link
Contributor Author

mauro3 commented Dec 1, 2016

This was fixed in 0.4. (The two AssertionErrors in my second post are correct and still present)

@mauro3 mauro3 closed this as completed Dec 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

2 participants