Skip to content

Commit 7179050

Browse files
erich-9Seelengrabgiordano
authored
Always return a value in 1-d circshift! of abstractarray.jl (JuliaLang#53554)
Co-authored-by: Sukera <[email protected]> Co-authored-by: Mosè Giordano <[email protected]>
1 parent 0f902bf commit 7179050

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

base/abstractarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3656,9 +3656,9 @@ end
36563656
## 1-d circshift ##
36573657
function circshift!(a::AbstractVector, shift::Integer)
36583658
n = length(a)
3659-
n == 0 && return
3659+
n == 0 && return a
36603660
shift = mod(shift, n)
3661-
shift == 0 && return
3661+
shift == 0 && return a
36623662
l = lastindex(a)
36633663
reverse!(a, firstindex(a), l-shift)
36643664
reverse!(a, l-shift+1, lastindex(a))

test/arrayops.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,14 @@ end
797797
oa = OffsetVector(copy(a), -1)
798798
@test circshift!(oa, 1) === oa
799799
@test oa == circshift(OffsetVector(a, -1), 1)
800+
801+
# 1d circshift! (#53554)
802+
a = []
803+
@test circshift!(a, 1) === a
804+
@test circshift!(a, 1) == []
805+
a = [1:5;]
806+
@test circshift!(a, 10) === a
807+
@test circshift!(a, 10) == 1:5
800808
end
801809

802810
@testset "circcopy" begin

0 commit comments

Comments
 (0)