Skip to content

Commit 0f2ed77

Browse files
authored
Fix error in validating complex row-first hvncat (#45365)
1 parent b77b54e commit 0f2ed77

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

base/abstractarray.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2396,14 +2396,17 @@ function _typed_hvncat_dims(::Type{T}, dims::NTuple{N, Int}, row_first::Bool, as
23962396
# validate shapes for lowest level of concatenation
23972397
d = findfirst(>(1), dims)
23982398
if d !== nothing # all dims are 1
2399+
if row_first && d < 3
2400+
d = d == 1 ? 2 : 1
2401+
end
23992402
nblocks = length(as) ÷ dims[d]
24002403
for b 1:nblocks
24012404
offset = ((b - 1) * dims[d])
24022405
startelementi = offset + 1
24032406
for i offset .+ (2:dims[d])
24042407
for dd 1:N
24052408
dd == d && continue
2406-
if size(as[startelementi], dd) != size(as[i], dd)
2409+
if cat_size(as[startelementi], dd) != cat_size(as[i], dd)
24072410
throw(ArgumentError("incompatible shape in element $i"))
24082411
end
24092412
end

test/abstractarray.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,8 @@ using Base: typed_hvncat
15431543
# Issue 43933 - semicolon precedence mistake should produce an error
15441544
@test_throws ArgumentError [[1 1]; 2 ;; 3 ; [3 4]]
15451545
@test_throws ArgumentError [[1 ;;; 1]; 2 ;;; 3 ; [3 ;;; 4]]
1546+
1547+
@test [[1 2; 3 4] [5; 6]; [7 8] 9;;;] == [1 2 5; 3 4 6; 7 8 9;;;]
15461548
end
15471549

15481550
@testset "keepat!" begin

0 commit comments

Comments
 (0)