Missings.jl icon indicating copy to clipboard operation
Missings.jl copied to clipboard

Operations on Array{Union{T,Missing},N} return Array{Any,N}

Open tbeason opened this issue 6 years ago • 4 comments

Example is pretty self explanatory I think. Output of @code_warntype says something isn't being inferred correctly.

julia> a=[1,missing,2]
3-element Array{Union{Int64, Missings.Missing},1}:
 1
  missing
 2

julia> a+2
3-element Array{Any,1}:
 3
  missing
 4

julia> a=[1 missing 2; 3 4 missing]
2×3 Array{Union{Int64, Missings.Missing},2}:
 1   missing  2
 3  4          missing

julia> a+2
2×3 Array{Any,2}:
 3   missing  4
 5  6          missing

I'm Julia 0.6.2 and Missings 0.2.4.

tbeason avatar Jan 19 '18 16:01 tbeason

Is it inferred correctly on 0.7? I'm not sure what we can do about inference on 0.6.

ararslan avatar Jan 19 '18 18:01 ararslan

Unfortunately, I haven't been able to get 0.7 running at all on my machine. Someone else would have to test

tbeason avatar Jan 19 '18 19:01 tbeason

It's not an inference issue, it's due to calling typejoin to choose the element type. https://github.com/JuliaLang/julia/pull/25553 should fix this.

nalimilan avatar Jan 19 '18 19:01 nalimilan

Oh, sorry to hear that. If you're having specific troubles I recommend asking on Discourse.

I just checked on 0.7 and it does indeed get inferred as Any there too.

ararslan avatar Jan 19 '18 19:01 ararslan