From 99a0db2af7dea8df25e146ea51b53954814eeb0b Mon Sep 17 00:00:00 2001 From: Nicholas Bauer Date: Thu, 19 May 2022 15:56:49 -0400 Subject: [PATCH] Fix error in validating complex row-first hvncat (#45365) --- base/abstractarray.jl | 5 ++++- test/abstractarray.jl | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 5dead91a3dbd5..444f56ac87749 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -2396,6 +2396,9 @@ function _typed_hvncat_dims(::Type{T}, dims::NTuple{N, Int}, row_first::Bool, as # validate shapes for lowest level of concatenation d = findfirst(>(1), dims) if d !== nothing # all dims are 1 + if row_first && d < 3 + d = d == 1 ? 2 : 1 + end nblocks = length(as) รท dims[d] for b โˆˆ 1:nblocks offset = ((b - 1) * dims[d]) @@ -2403,7 +2406,7 @@ function _typed_hvncat_dims(::Type{T}, dims::NTuple{N, Int}, row_first::Bool, as for i โˆˆ offset .+ (2:dims[d]) for dd โˆˆ 1:N dd == d && continue - if size(as[startelementi], dd) != size(as[i], dd) + if cat_size(as[startelementi], dd) != cat_size(as[i], dd) throw(ArgumentError("incompatible shape in element $i")) end end diff --git a/test/abstractarray.jl b/test/abstractarray.jl index a9236ecf5d5be..f68acce07ba29 100644 --- a/test/abstractarray.jl +++ b/test/abstractarray.jl @@ -1543,6 +1543,8 @@ using Base: typed_hvncat # Issue 43933 - semicolon precedence mistake should produce an error @test_throws ArgumentError [[1 1]; 2 ;; 3 ; [3 4]] @test_throws ArgumentError [[1 ;;; 1]; 2 ;;; 3 ; [3 ;;; 4]] + + @test [[1 2; 3 4] [5; 6]; [7 8] 9;;;] == [1 2 5; 3 4 6; 7 8 9;;;] end @testset "keepat!" begin