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

Amiguity warning #6423

Closed
daviddelaat opened this issue Apr 5, 2014 · 5 comments
Closed

Amiguity warning #6423

daviddelaat opened this issue Apr 5, 2014 · 5 comments

Comments

@daviddelaat
Copy link
Contributor

The following code which doesn't seem ambiguous to me gives an ambiguity warning:

type A{T}; end
type B{T}; end

f{T}(::T, ::A{T}) = 1
f{T}(::B{T}, ::T) = 2
@StefanKarpinski
Copy link
Member

What if the first T is B and the second T is A? Then you get

f(::B, ::A{B}) = 1
f(::B{A}, ::A) = 2

The intersection case is f(::B{A}, ::A{B}).

@daviddelaat
Copy link
Contributor Author

But you can't just substitute an abstract type for T right?
For instance, if I define

g{T}(::T, ::T) = 1

then there is no method g(::Array, ::Array) = 1 because I can't call g([1], [1.0]).

@StefanKarpinski
Copy link
Member

A{B} and B{A} are concrete types and A{B} <: A and B{A} <: B, hence the ambiguity.

@JeffBezanson
Copy link
Member

Duplicate of #1631

@daviddelaat
Copy link
Contributor Author

Aah, sorry about that, hadn't seen the other issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants