Skip to content

Commit

Permalink
Fix undef in cat for eltypes that are not <:Number (#36222)
Browse files Browse the repository at this point in the history
  • Loading branch information
lassepe committed Jun 16, 2020
1 parent 9ed10de commit 1558e76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ _cat(dims, X...) = cat_t(promote_eltypeof(X...), X...; dims=dims)
catdims = dims2cat(dims)
shape = cat_shape(catdims, (), map(cat_size, X)...)
A = cat_similar(X[1], T, shape)
if T <: Number && count(!iszero, catdims) > 1
if count(!iszero, catdims) > 1
fill!(A, zero(T))
end
return __cat(A, shape, catdims, X...)
Expand Down
4 changes: 4 additions & 0 deletions test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,10 @@ function test_cat(::Type{TestAbstractArray})
# 29172
@test_throws ArgumentError cat([1], [2], dims=0)
@test_throws ArgumentError cat([1], [2], dims=[5, -3])

# 36041
@test_throws MethodError cat(["a"], ["b"], dims=[1, 2])
@test cat([1], [1], dims=[1, 2]) == I(2)
end

function test_ind2sub(::Type{TestAbstractArray})
Expand Down

0 comments on commit 1558e76

Please sign in to comment.