Get ambiguous method candidates

struct Foo end
struct Bar end

f(x::Foo, y) = 2
f(x, y::Bar) = 3

f(Foo(), Bar()) # ambiguous

This errors because of ambiguity. How can I get the list of candidate functions? I’m not sure why

methods(f, (Foo, Bar))

returns empty.

This seems to work:

julia> Base.methods_including_ambiguous(f, Tuple{Foo, Bar})
# 2 methods for generic function "f":
[1] f(x::Foo, y) in Main at REPL[6]:1
[2] f(x, y::Bar) in Main at REPL[7]:1
1 Like