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

Inconsistent type inference for getindex(BitArray{2}, Int64, Range1{Int64}) #3400

Closed
simonster opened this issue Jun 15, 2013 · 4 comments
Closed
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@simonster
Copy link
Member

There's a test in DataFrames that's intermittently failing due to something that looks like an inference bug. When I run finfer(getindex, (BitArray{2}, Int64, Range1{Int64})) immediately after starting Julia, I sometimes get:

finfer(getindex, (BitArray{2}, Int64, Range1{Int64}))
:($(Expr(:lambda, {:B, :(I::top(apply_type)(Vararg,Union(Real,AbstractVector)))}, {{:X, :Xc}, {{:B, BitArray{2}, 0}, {:I, Any, 2}, {:X, BitArray{2}, 2}, {:Xc, Array{Uint64,1}, 2}}, {{:getindex_cache, Any, 7}}}, quote  # bitarray.jl, line 471:
        I = top(tuple)(indices(tupleref(I::(Int64,Range1{Int64}),1)::Union(Range1{Int64},Int64)),indices(tupleref(I::(Int64,Range1{Int64}),2)::Union(Range1{Int64},Int64)))::(Any,Any) # line 472:
        X = BitArray(index_shape(top(tupleref)(I::(Any,Any),1),top(tupleref)(I::(Any,Any),2))::Union((),(Any,),(Any,Any)))::BitArray{2} # line 473:
        Xc = top(getfield)(X::BitArray{2},:chunks)::Array{Uint64,1} # line 475:
        unless is(getindex_cache,nothing)::Bool goto 0 # line 476:
        getindex_cache = $(Dict{Any,Any})()::Dict{Any,Any}
        0:  # line 478:
        gen_cartesian_map(getindex_cache,$(AST(:($(Expr(:lambda, {:(ivars::Any)}, {{:#s143, :#s137}, {{:ivars, Any, 0}, {:#s143, Array{Any,1}, 2}, {:#s137, Array{Any,1}, 2}}, {}}, quote  # bitarray.jl, line 478:
        #s143 = top(ccall)(:jl_alloc_array_1d,$(Array{Any,1}),top(tuple)(Any,Int)::(Type{Any},Type{Int64}),$(Array{Any,1}),0,1,0)::Array{Any,1}
        top(arrayset)(#s143::Array{Any,1},:B,1)::Array{Any,1}
        #s137 = #s143::Array{Any,1}
        return top(Expr)(:block,top(Expr)(:line,480,:bitarray.jl)::Expr,top(Expr)(:call,:setindex_unchecked,:Xc,top(splicedexpr)(:ref,top(append_any)(#s137::Array{Any,1},ivars)::Array{Any,1})::Expr,:ind)::Expr,top(Expr)(:line,481)::Expr,top(Expr)(:+=,:ind,1)::Expr)::Expr
    end))))),I::(Any,Any),top(tuple)(:B,:Xc,:ind)::(Symbol,Symbol,Symbol),B::BitArray{2},Xc::Array{Uint64,1},1) # line 483:
        return X::BitArray{2}
    end)))

which looks okay. Other times I get:

finfer(getindex, (BitArray{2}, Int64, Range1{Int64}))
:($(Expr(:lambda, {:B, :(I::top(apply_type)(Vararg,Union(Real,AbstractVector)))}, {{:X, :Xc}, {{:B, BitArray{2}, 0}, {:I, Any, 2}, {:X, BitArray{1}, 2}, {:Xc, Array{Uint64,1}, 2}}, {{:getindex_cache, Any, 7}}}, quote  # bitarray.jl, line 471:
        I = top(tuple)(indices(tupleref(I::(Int64,Range1{Int64}),1)::Union(Int64,Range1{Int64})),indices(tupleref(I::(Int64,Range1{Int64}),2)::Union(Int64,Range1{Int64})))::(Any,Any) # line 472:
        X = BitArray(index_shape(top(tupleref)(I::(Any,Any),1),top(tupleref)(I::(Any,Any),2))::Union((),(Any,Any),(Any,)))::BitArray{1} # line 473:
        Xc = top(getfield)(X::BitArray{1},:chunks)::Array{Uint64,1} # line 475:
        unless is(getindex_cache,nothing)::Bool goto 0 # line 476:
        getindex_cache = $(Dict{Any,Any})()::Dict{Any,Any}
        0:  # line 478:
        gen_cartesian_map(getindex_cache,$(AST(:($(Expr(:lambda, {:(ivars::Any)}, {{:#s143, :#s137}, {{:ivars, Any, 0}, {:#s143, Array{Any,1}, 2}, {:#s137, Array{Any,1}, 2}}, {}}, quote  # bitarray.jl, line 478:
        #s143 = top(ccall)(:jl_alloc_array_1d,$(Array{Any,1}),top(tuple)(Any,Int)::(Type{Any},Type{Int64}),$(Array{Any,1}),0,1,0)::Array{Any,1}
        top(arrayset)(#s143::Array{Any,1},:B,1)::Array{Any,1}
        #s137 = #s143::Array{Any,1}
        return top(Expr)(:block,top(Expr)(:line,480,:bitarray.jl)::Expr,top(Expr)(:call,:setindex_unchecked,:Xc,top(splicedexpr)(:ref,top(append_any)(#s137::Array{Any,1},ivars)::Array{Any,1})::Expr,:ind)::Expr,top(Expr)(:line,481)::Expr,top(Expr)(:+=,:ind,1)::Expr)::Expr
    end))))),I::(Any,Any),top(tuple)(:B,:Xc,:ind)::(Symbol,Symbol,Symbol),B::BitArray{2},Xc::Array{Uint64,1},1) # line 483:
        return X::BitArray{1}
    end)))

which gives the wrong return type.

@ghost ghost assigned JeffBezanson Jun 15, 2013
@JeffBezanson
Copy link
Member

same root cause as #3167

vtjnash added a commit that referenced this issue Jul 25, 2013
vtjnash added a commit that referenced this issue Aug 20, 2013
…at may actually get called for the argument tuple
@simonster
Copy link
Member Author

Should this be closed? The symptoms here are definitely gone, although it's unclear to me whether the underlying issue is fixed.

@pao
Copy link
Member

pao commented Apr 7, 2014

If the underlying issue is #3167, this should be safe to close as duplicate, unless the thought is the root cause isn't in fact the same.

@quinnj
Copy link
Member

quinnj commented Jun 23, 2014

Closing as dup of #3167

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
Projects
None yet
Development

No branches or pull requests

4 participants