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

Method call mixups when iterating over TypeVars #10778

Closed
mauro3 opened this issue Apr 9, 2015 · 0 comments
Closed

Method call mixups when iterating over TypeVars #10778

mauro3 opened this issue Apr 9, 2015 · 0 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior types and dispatch Types, subtyping and method dispatch

Comments

@mauro3
Copy link
Contributor

mauro3 commented Apr 9, 2015

Somehow Julia (0.3 & 0.4) gets confused which start method should be called (namely none):

function f(m::Method)
    @show m.tvars, typeof(m.tvars), methods(start, (typeof(m.tvars),))
    i = 1
    for t in m.tvars
        i += 1
        if i>=10^5
            break
        end
    end
    i
end

g(x) = 5
@show f(g.env.defs) # == 1


h{T}(x::T) = 5
@show f(h.env.defs) # == 10^5 !

m = h.env.defs
@show m.tvars, typeof(m.tvars), methods(start, (typeof(m.tvars),))
for t in m.tvars
    @show "a"
end

0.4 output:

(m.tvars,typeof(m.tvars),methods(start,(typeof(m.tvars),))) = ((),(),Any[start(t::(Any...,)) at tuple.jl:13])
f(g.env.defs) = 1
(m.tvars,typeof(m.tvars),methods(start,(typeof(m.tvars),))) = (T,TypeVar,Any[start{T<:Base.Enums.Enum}(::Type{T<:Base.Enums.Enum}) at Enums.jl:9])
f(h.env.defs) = 100001
(m.tvars,typeof(m.tvars),methods(start,(typeof(m.tvars),))) = (T,TypeVar,Any[start{T<:Base.Enums.Enum}(::Type{T<:Base.Enums.Enum}) at Enums.jl:9])
ERROR: LoadError: no method found for the specified argument types
 in which at reflection.jl:187
 in include at ./boot.jl:250
 in include_from_node1 at loading.jl:129
 in process_options at ./client.jl:317
 in _start at ./client.jl:401

0.3 output:

(m.tvars,typeof(m.tvars),methods(start,(typeof(m.tvars),))) => ((),(),{start(t::(Any...,)) at tuple.jl:13})
f(g.env.defs) => 1
(m.tvars,typeof(m.tvars),methods(start,(typeof(m.tvars),))) => (T,TypeVar,{})
f(h.env.defs) => 100001
(m.tvars,typeof(m.tvars),methods(start,(typeof(m.tvars),))) => (T,TypeVar,{})
ERROR: `start` has no method matching start(::TypeVar)
 in anonymous at no file
 in include at ./boot.jl:245
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:285
 in _start at ./client.jl:354

Also, only on 0.4:

julia> methods(start ,(TypeVar,))
1-element Array{Any,1}:
 start{T<:Base.Enums.Enum}(::Type{T<:Base.Enums.Enum}) at Enums.jl:9
@ihnorton ihnorton added the types and dispatch Types, subtyping and method dispatch label Apr 11, 2015
@JeffBezanson JeffBezanson self-assigned this Apr 17, 2015
@JeffBezanson JeffBezanson added the bug Indicates an unexpected problem or unintended behavior label Apr 19, 2015
mbauman pushed a commit to mbauman/julia that referenced this issue Jun 6, 2015
This is how things were in 0.3. The change was an experiment that didn't work out.
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

3 participants