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

Problem with argument types (already fixed in 0.4) #9082

Closed
lmshk opened this issue Nov 20, 2014 · 2 comments
Closed

Problem with argument types (already fixed in 0.4) #9082

lmshk opened this issue Nov 20, 2014 · 2 comments

Comments

@lmshk
Copy link

lmshk commented Nov 20, 2014

In 0.3.2, when defining

f{T}(x::T, ::Type{T}) = println("Yes: ", x)
f(x, ::Type) = println("No: ", x)

I would expect the first method to match iff x' type is a subtype of the second argument. It works for

f(1, Int) # prints "Yes: 1"
f(1.0, Int) # prints "No: 1.0"

but not for

f(1, Number) # prints "No: 1"

This is actually works in 0.4. @simonster said that this should probably also work in 0.3. Can it be backported? (I would be willing to do this myself if someone points me in the right direction.)

@jiahao
Copy link
Member

jiahao commented Nov 20, 2014

I think this works in 0.4 because of the change to call constructors in #8712; the change in diagonal dispatch behavior came up in #8974 (comment). I don't think it makes sense to backport such a large change to the language.

@JeffBezanson
Copy link
Sponsor Member

Yes this was a deliberate change for 0.4. It changes method applicability and is definitely not a bug fix, so this can't be backported.

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