JuliaLang/julia — pull request #4387 by simonster (2013-09-27 21:45:28+00:00)
Title: Infer element type for general multi-dimensional getindex

For `getindex(A::Array, I::Union(Real,AbstractVector)...)` Julia can't infer the return type of `index_shape`, which means it can't infer whether this code will call `similar(a::AbstractArray{T,N},T)` or `similar{T}(a::AbstractArray{T,N},dims::(Int64...,))`, which means it can't infer the element type of the array that `getindex` returns, which is bad. This patch works around this by explicitly specifying the element type. It would be better if we could infer the dimensionality as well, but that seems harder.