Skip to content

Commit 01be772

Browse files
committed
Make view() propagate inbounds
This matches Base behavior
1 parent a9333fa commit 01be772

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/MArray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ end
7171
return any(index -> index <: StaticVector{<:Any,Bool}, indices.parameters)
7272
end
7373

74-
function Base.view(
74+
@propagate_inbounds function Base.view(
7575
a::MArray{S},
7676
indices::Union{Integer, Colon, StaticVector, Base.Slice, SOneTo}...,
7777
) where {S}

src/SizedArray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ end
155155
return Tuple{prod_size}
156156
end
157157

158-
function Base.view(
158+
@propagate_inbounds function Base.view(
159159
a::SizedArray{S},
160160
indices::Union{Integer, Colon, StaticVector, Base.Slice, SOneTo}...,
161161
) where {S}

src/abstractarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ end
287287
# wrap elements in Scalar to be consistent with 0D views
288288
_maybewrapscalar(::Tuple{}, r::T) where {T} = Scalar{T}(r)
289289
_maybewrapscalar(_, r) = r
290-
function Base.view(S::SArray, I::Union{Colon, Integer, SOneTo, StaticArray{<:Tuple, Int}, CartesianIndex}...)
290+
@propagate_inbounds function Base.view(S::SArray, I::Union{Colon, Integer, SOneTo, StaticArray{<:Tuple, Int}, CartesianIndex}...)
291291
V = getindex(S, I...)
292292
_maybewrapscalar(Base.index_dimsum(I...), V)
293293
end

0 commit comments

Comments
 (0)