Skip to content

Commit 5a06515

Browse files
authored
Inference of circcopy and circshift (#35398)
fixes #35396, fixes #35248
1 parent 39134c5 commit 5a06515

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

base/multidimensional.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ circshift!(dest::AbstractArray, src, shiftamt) = circshift!(dest, src, (shiftamt
10151015
# _circshift!(dest, src, ("second half of dim1", "second half of dim2")) --> copyto!
10161016
@inline function _circshift!(dest, rdest, src, rsrc,
10171017
inds::Tuple{AbstractUnitRange,Vararg{Any}},
1018-
shiftamt::Tuple{Integer,Vararg{Any}})
1018+
shiftamt::Tuple{Integer,Vararg{Any}})::typeof(dest)
10191019
ind1, d = inds[1], shiftamt[1]
10201020
s = mod(d, length(ind1))
10211021
sf, sl = first(ind1)+s, last(ind1)-s
@@ -1075,7 +1075,7 @@ end
10751075

10761076
# This uses the same strategy described above for _circshift!
10771077
@inline function _circcopy!(dest, rdest, indsdest::Tuple{AbstractUnitRange,Vararg{Any}},
1078-
src, rsrc, indssrc::Tuple{AbstractUnitRange,Vararg{Any}})
1078+
src, rsrc, indssrc::Tuple{AbstractUnitRange,Vararg{Any}})::typeof(dest)
10791079
indd1, inds1 = indsdest[1], indssrc[1]
10801080
l = length(indd1)
10811081
s = mod(first(inds1)-first(indd1), l)

test/arrayops.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,18 @@ end
728728
a = [1:5;]
729729
@test_throws ArgumentError Base.circshift!(a, a, 1)
730730
b = copy(a)
731-
@test Base.circshift!(b, a, 1) == [5,1,2,3,4]
731+
@test @inferred(Base.circshift!(b, a, 1) == [5,1,2,3,4])
732+
src=rand(3,4,5)
733+
dst=similar(src)
734+
s=(1,2,3)
735+
@inferred Base.circshift!(dst,src,s)
732736
end
733737

738+
@testset "circcopy" begin
739+
src=rand(3,4,5)
740+
dst=similar(src)
741+
@inferred Base.circcopy!(dst,src)
742+
end
734743
# unique across dim
735744

736745
# With hash collisions

0 commit comments

Comments
 (0)