diff --git a/base/abstractarray.jl b/base/abstractarray.jl index b605cdcb7f183..70d1fd4828d4e 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -1493,6 +1493,7 @@ function hvcat_fill(a::Array, xs::Tuple) end hvcat(rows::Tuple{Vararg{Int}}, xs::Number...) = typed_hvcat(promote_typeof(xs...), rows, xs...) +hvcat(rows::Tuple{Vararg{Int}}, xs...) = typed_hvcat(promote_eltypeof(xs...), rows, xs...) function typed_hvcat(::Type{T}, rows::Tuple{Vararg{Int}}, xs::Number...) where T nr = length(rows) @@ -1509,18 +1510,6 @@ function typed_hvcat(::Type{T}, rows::Tuple{Vararg{Int}}, xs::Number...) where T hvcat_fill(Array{T,2}(nr, nc), xs) end -# fallback definition of hvcat in terms of hcat and vcat -function hvcat(rows::Tuple{Vararg{Int}}, as...) - nbr = length(rows) # number of block rows - rs = Array{Any,1}(nbr) - a = 1 - for i = 1:nbr - rs[i] = hcat(as[a:a-1+rows[i]]...) - a += rows[i] - end - vcat(rs...) -end - function typed_hvcat(::Type{T}, rows::Tuple{Vararg{Int}}, as...) where T nbr = length(rows) # number of block rows rs = Array{Any,1}(nbr) diff --git a/test/arrayops.jl b/test/arrayops.jl index 752b6c94d69a0..a78bffc27d3a4 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -413,6 +413,14 @@ end @test X32[i:(i+1), j:(j+2)] == X end end +@testset "fallback hvcat" begin + #Issue #23994 + A23994 = [1 "two"; 3im 4.0; 5 6//1] + @test A23994[2] isa Complex{Int} + @test A23994[3] isa Int + @test A23994[5] isa Float64 + @test A23994[6] isa Rational{Int} +end @testset "end" begin X = [ i+2j for i=1:5, j=1:5 ] @test X[end,end] == 15