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

avoid suggesting a method that will not work to resolve a method ambiguity #33852

Merged
merged 1 commit into from
Nov 15, 2019

Conversation

JeffBezanson
Copy link
Sponsor Member

Example:

julia> f33789(x::I, ft::Function, use::Type{U}, ignore::Type{I}) where {U, I} = 0;

julia> f33789(x::U, ft::Function, use::Type{U}, ignore::Type{I}) where {U, I} = 1;

julia> f33789(1.0f0, identity, Number, Float32)
ERROR: MethodError: f33789(::Float32, ::typeof(identity), ::Type{Number}, ::Type{Float32}) is ambiguous. Candidates:
  f33789(x::I, ft::Function, use::Type{U}, ignore::Type{I}) where {U, I} in Main at REPL[1]:1
  f33789(x::U, ft::Function, use::Type{U}, ignore::Type{I}) where {U, I} in Main at REPL[2]:1
To resolve the ambiguity, try making one or more of the methods more specific, or adding a new method more specific than any of the existing applicable methods.

@JeffBezanson JeffBezanson added the types and dispatch Types, subtyping and method dispatch label Nov 14, 2019
@aminya
Copy link

aminya commented Nov 15, 2019

So this PR makes Julia give a better error message in case of the method ambiguity. The issue's title is a bit misleading.

@JeffBezanson JeffBezanson changed the title avoid giving useless suggestions for method ambiguities avoid suggesting a method that will not work to resolve a method ambiguity Nov 15, 2019
@vtjnash vtjnash merged commit 1b03919 into master Nov 15, 2019
@vtjnash vtjnash deleted the jb/ambiguityerror branch November 15, 2019 19:28
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

Successfully merging this pull request may close these issues.

5 participants