Methods() returning duplicate results?

question

#1

The methods function appears to return duplicate results in this case, is that a bug?

REPL input:

foo(arg1::Union{Int32,Int64}, arg2::Union{Float64,Int64}) = 1
methods(foo, (Union{Int32,Int64},Union{Float64,Int64}))

output:

foo(arg1::Union{Int32,Int64}, arg2::Union{Float64,Int64}) at REPL[1]:1
foo(arg1::Union{Int32,Int64}, arg2::Union{Float64,Int64}) at REPL[1]:1
foo(arg1::Union{Int32,Int64}, arg2::Union{Float64,Int64}) at REPL[1]:1
foo(arg1::Union{Int32,Int64}, arg2::Union{Float64,Int64}) at REPL[1]:1


#2

Which version are you on? I can reproduce this on v"0.6.0-dev.2539", and agree it looks like a bug not a feature. (I figure: when providing a type signature with a union, it should filter methods taking the whole set, not methods taking any subset. But that’s debatable.) If it’s the same on the current master build, then a bug report (or a PR!) on github would be appropriate, are you happy making one?

Smaller repo:

julia> bar(x::Union{Int8,Int16}) = 2;

julia> methods(bar)
# 1 method for generic function "bar":
bar(x::Union{Int16, Int8}) in Main at console:1

julia> methods(bar,[Union{Int8,Int16}])
# 2 methods for generic function "bar":
bar(x::Union{Int16, Int8}) in Main at console:1
bar(x::Union{Int16, Int8}) in Main at console:1

julia> methods(bar,[Union{Int8,Int32}])
# 1 method for generic function "bar":
bar(x::Union{Int16, Int8}) in Main at console:1