Skip to content

Commit 4e6d50c

Browse files
authored
Merge branch 'JuliaArrays:master' into master
2 parents 7bd7cdb + e7c5e01 commit 4e6d50c

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "StaticArrays"
22
uuid = "90137ffa-7385-5640-81b9-e52037218182"
3-
version = "1.9.13"
3+
version = "1.9.14"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/abstractarray.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,11 @@ end
285285
# SArrays may avoid the SubArray wrapper and consequently an additional level of indirection
286286
# The output may use the broadcasting machinery defined for StaticArrays (see issue #892)
287287
# wrap elements in Scalar to be consistent with 0D views
288-
_maybewrapscalar(S::SArray{<:Any,T}, r::T) where {T} = Scalar{T}(r)
289-
_maybewrapscalar(S, r) = r
288+
_maybewrapscalar(::Tuple{}, r::T) where {T} = Scalar{T}(r)
289+
_maybewrapscalar(_, r) = r
290290
function Base.view(S::SArray, I::Union{Colon, Integer, SOneTo, StaticArray{<:Tuple, Int}, CartesianIndex}...)
291291
V = getindex(S, I...)
292-
_maybewrapscalar(S, V)
292+
_maybewrapscalar(Base.index_dimsum(I...), V)
293293
end
294294

295295
# zeros, ones and fill may return SArrays if all the axes are statically sized

test/indexing.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,4 +253,16 @@ using StaticArrays, Test
253253
@test lastindex(ind[3]) === 2
254254
@test size(ind[3]) === (2,)
255255
end
256+
257+
@testset "Array view into `Any` eltype `SArray`" begin
258+
A = SVector{4, Any}(1,2,3,4)
259+
v = @inferred view(A, SA[3, 1])
260+
@test v == SVector{2, Any}(3, 1)
261+
A = SMatrix{2, 2, Any}(1, 2, 3, 4)
262+
v = @inferred view(A, @SArray(fill(1, 1, 1)))
263+
@test v == SMatrix{1, 1, Any}(1)
264+
A = SArray{Tuple{2, 2, 2}, Any}(1, 2, 3, 4, 5, 6, 7, 8)
265+
v = @inferred view(A, @SArray(fill(1, 1, 1, 1)))
266+
@test v == SArray{Tuple{1, 1, 1}, Any}(1)
267+
end
256268
end

0 commit comments

Comments
 (0)