Skip to content

Commit e542198

Browse files
rfourquetsimeonschaub
authored andcommitted
fix stackoverflow in circshift!(x, y, (1.0,)) (JuliaLang#36734)
1 parent 1dfb9bb commit e542198

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

base/multidimensional.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,9 @@ See also [`circshift`](@ref).
10261026
axes(dest) == inds || throw(ArgumentError("indices of src and dest must match (got $inds and $(axes(dest)))"))
10271027
_circshift!(dest, (), src, (), inds, fill_to_length(shiftamt, 0, Val(N)))
10281028
end
1029-
circshift!(dest::AbstractArray, src, shiftamt) = circshift!(dest, src, (shiftamt...,))
1029+
1030+
circshift!(dest::AbstractArray, src, shiftamt) =
1031+
circshift!(dest, src, map(Integer, (shiftamt...,)))
10301032

10311033
# For each dimension, we copy the first half of src to the second half
10321034
# of dest, and the second half of src to the first half of dest. This

test/arrayops.jl

+9
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,15 @@ end
733733
dst=similar(src)
734734
s=(1,2,3)
735735
@inferred Base.circshift!(dst,src,s)
736+
737+
src = [1 2 3; 4 5 6]
738+
dst = similar(src)
739+
@test circshift(src, (3, 2)) == [5 6 4; 2 3 1]
740+
@test circshift(src, (3.0, 2.0)) == [5 6 4; 2 3 1]
741+
res = circshift!(dst, src, (3, 2))
742+
@test res === dst == [5 6 4; 2 3 1]
743+
res = circshift!(dst, src, (3.0, 2.0))
744+
@test res === dst == [5 6 4; 2 3 1]
736745
end
737746

738747
@testset "circcopy" begin

0 commit comments

Comments
 (0)