diff --git a/base/abstractarraymath.jl b/base/abstractarraymath.jl index 9e6cd7af7ca23..e5ca36f71ac0a 100644 --- a/base/abstractarraymath.jl +++ b/base/abstractarraymath.jl @@ -377,7 +377,8 @@ _reperr(s, n, N) = throw(ArgumentError("number of " * s * " repetitions " * # fill the first inner block if all(x -> x == 1, inner) - R[axes(A)...] = A + idxs = (axes(A)..., ntuple(n->OneTo(1), ndims(R)-ndims(A))...) # keep dimension consistent + R[idxs...] = A else inner_indices = [1:n for n in inner] for c in CartesianIndices(axes(A)) diff --git a/test/arrayops.jl b/test/arrayops.jl index b15bcc3779fde..9ccccb9817fa1 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -699,6 +699,12 @@ end @test_throws MethodError repeat(1, 2, 3) @test repeat([1, 2], 1, 2, 3) == repeat([1, 2], outer = (1, 2, 3)) + # issue 29614 + @test repeat(ones(2, 2), 1, 1, 1) == ones(2, 2, 1) + @test repeat(ones(2, 2), 2, 2, 2) == ones(4, 4, 2) + @test repeat(ones(2), 2, 2, 2) == ones(4, 2, 2) + @test repeat(ones(2, 2), inner=(1, 1, 1), outer=(2, 2, 2)) == ones(4, 4, 2) + R = repeat([1, 2]) @test R == [1, 2] R = repeat([1, 2], inner=1)