Skip to content

Commit

Permalink
fix stackoverflow in circshift!(x, y, (1.0,)) (#36734)
Browse files Browse the repository at this point in the history
(cherry picked from commit 773ef66)
  • Loading branch information
rfourquet committed Jul 24, 2020
1 parent 7665916 commit 5091177
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,9 @@ See also [`circshift`](@ref).
axes(dest) == inds || throw(ArgumentError("indices of src and dest must match (got $inds and $(axes(dest)))"))
_circshift!(dest, (), src, (), inds, fill_to_length(shiftamt, 0, Val(N)))
end
circshift!(dest::AbstractArray, src, shiftamt) = circshift!(dest, src, (shiftamt...,))

circshift!(dest::AbstractArray, src, shiftamt) =
circshift!(dest, src, map(Integer, (shiftamt...,)))

# For each dimension, we copy the first half of src to the second half
# of dest, and the second half of src to the first half of dest. This
Expand Down
9 changes: 9 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,15 @@ end
dst=similar(src)
s=(1,2,3)
@inferred Base.circshift!(dst,src,s)

src = [1 2 3; 4 5 6]
dst = similar(src)
@test circshift(src, (3, 2)) == [5 6 4; 2 3 1]
@test circshift(src, (3.0, 2.0)) == [5 6 4; 2 3 1]
res = circshift!(dst, src, (3, 2))
@test res === dst == [5 6 4; 2 3 1]
res = circshift!(dst, src, (3.0, 2.0))
@test res === dst == [5 6 4; 2 3 1]
end

@testset "circcopy" begin
Expand Down

0 comments on commit 5091177

Please sign in to comment.