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

typealias bug? #2552

Closed
StefanKarpinski opened this issue Mar 12, 2013 · 7 comments
Closed

typealias bug? #2552

StefanKarpinski opened this issue Mar 12, 2013 · 7 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior types and dispatch Types, subtyping and method dispatch

Comments

@StefanKarpinski
Copy link
Member

julia> typealias SelfDict{T} Dict{T,T}
Dict{T,T}

julia> isself(d::Dict) = false
# methods for generic function isself
isself(d::Dict{K,V}) at none:1

julia> isself(d::SelfDict) = true
# methods for generic function isself
isself(d::Dict{T,T}) at none:1

julia> isself([1=>2])
true

julia> isself([1=>"foo"])
true
@ghost ghost assigned JeffBezanson Mar 14, 2013
@JeffBezanson
Copy link
Member

Yeah this isn't implemented yet. We need to convert it to the normal form isself{T}(d::SelfDict{T}) which is a bit tricky.

@mbauman
Copy link
Member

mbauman commented Jul 9, 2015

Is this the same root cause as the following method ordering bug?

julia> type A{T<:Integer}; end

julia> f{T}(::A{T}) = 1      # Julia doesn't consider that T must be <: Integer here
       f(::A, ::Any...) = 2  # But implicitly does so here
f (generic function with 2 methods)

julia> f(A{Int}())           # So method 2 is more specific
2

julia> g{T<:Integer}(::A{T}) = 1 # But if I manually tell Julia about the restriction
       g(::A, ::Any...) = 2
g (generic function with 2 methods)

julia> g(A{Int}())  # Then dispatch works as expected
1

@yuyichao
Copy link
Contributor

yuyichao commented Jul 9, 2015

@mbauman Feels like a variant of #11597 ?

@mbauman
Copy link
Member

mbauman commented Jul 9, 2015

Yes, that's much more applicable. I came here from #7453, which also seemed similar but was closed as a duplicate of this guy. It's not really a typealias problem though — it's a restricted type parameter. So I wasn't sure if the same restricting/unrestricting problem was at the root cause here.

@yuyichao
Copy link
Contributor

yuyichao commented Jul 9, 2015

Actually thanks for pinging this, since I actually notice exactly this a few days ago.

@vtjnash
Copy link
Member

vtjnash commented Aug 24, 2015

removing the milestone tag since this is being tracked through #8974

@vtjnash vtjnash removed this from the 0.4.x milestone Aug 24, 2015
@JeffBezanson JeffBezanson added the types and dispatch Types, subtyping and method dispatch label Jun 21, 2016
@JeffBezanson
Copy link
Member

closed by #18457

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

5 participants