Skip to content

Commit

Permalink
Fix error in validating complex row-first hvncat (#45365)
Browse files Browse the repository at this point in the history
  • Loading branch information
BioTurboNick authored and pull[bot] committed Jul 6, 2022
1 parent c0e0fde commit 99a0db2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2396,14 +2396,17 @@ 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])
startelementi = offset + 1
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
Expand Down
2 changes: 2 additions & 0 deletions test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 99a0db2

Please sign in to comment.