Skip to content

Commit b3b1eeb

Browse files
committed
Reduce specificity for scalar indexing
1 parent 3972ccd commit b3b1eeb

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/indexing.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ setindex!(a::StaticArray, value, i::Int) = error("setindex!(::$(typeof(a)), valu
88

99
# Note: all indexing behavior defaults to dense, linear indexing
1010

11-
@propagate_inbounds function getindex(a::StaticArray{<:Tuple,<:Any,N}, inds::Vararg{Int,N}) where N
11+
@propagate_inbounds function getindex(a::StaticArray, inds::Int...)
1212
@boundscheck checkbounds(a, inds...)
1313
_getindex_scalar(Size(a), a, inds...)
1414
end
@@ -30,7 +30,7 @@ end
3030
end
3131
end
3232

33-
@propagate_inbounds function setindex!(a::StaticArray{<:Tuple,<:Any,N}, value, inds::Vararg{Int,N}) where N
33+
@propagate_inbounds function setindex!(a::StaticArray, value, inds::Int...)
3434
@boundscheck checkbounds(a, inds...)
3535
_setindex!_scalar(Size(a), a, value, inds...)
3636
end

test/indexing.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ using StaticArrays, Test
7373
@test @SVector([1,2,3,4])[@SMatrix([1 2; 3 4])] === @SMatrix([1 2; 3 4])
7474
end
7575

76+
@testset "2D getindex() on SVector" begin
77+
v = @SVector [1,2]
78+
@test v[1,1] == 1
79+
@test v[2,1] == 2
80+
@test_throws BoundsError v[1,2]
81+
@test_throws BoundsError v[3,1]
82+
end
83+
7684
@testset "2D getindex() on SMatrix" begin
7785
sm = @SMatrix [1 3; 2 4]
7886

0 commit comments

Comments
 (0)