Skip to content

Commit

Permalink
Merge pull request JuliaLang#10133 from JuliaLang/mb/checkcolons
Browse files Browse the repository at this point in the history
Allow Colons in checkbounds
  • Loading branch information
timholy committed Feb 9, 2015
2 parents a85e6b7 + acd0739 commit 8614188
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ linearindexing{A<:Array}(::Type{A}) = LinearFast()
linearindexing{A<:Range}(::Type{A}) = LinearFast()

## Bounds checking ##
checkbounds(sz::Int, ::Colon) = nothing
checkbounds(sz::Int, i::Int) = 1 <= i <= sz || throw(BoundsError())
checkbounds(sz::Int, i::Real) = checkbounds(sz, to_index(i))
checkbounds(sz::Int, I::AbstractVector{Bool}) = length(I) == sz || throw(BoundsError())
Expand All @@ -91,17 +92,17 @@ checkbounds(A::AbstractArray, I::AbstractArray{Bool}) = size(A) == size(I) || th

checkbounds(A::AbstractArray, I) = checkbounds(length(A), I)

function checkbounds(A::AbstractMatrix, I::Union(Real,AbstractArray), J::Union(Real,AbstractArray))
function checkbounds(A::AbstractMatrix, I::Union(Real,Colon,AbstractArray), J::Union(Real,Colon,AbstractArray))
checkbounds(size(A,1), I)
checkbounds(size(A,2), J)
end

function checkbounds(A::AbstractArray, I::Union(Real,AbstractArray), J::Union(Real,AbstractArray))
function checkbounds(A::AbstractArray, I::Union(Real,Colon,AbstractArray), J::Union(Real,Colon,AbstractArray))
checkbounds(size(A,1), I)
checkbounds(trailingsize(A,2), J)
end

function checkbounds(A::AbstractArray, I::Union(Real,AbstractArray)...)
function checkbounds(A::AbstractArray, I::Union(Real,Colon,AbstractArray)...)
n = length(I)
if n > 0
for dim = 1:(n-1)
Expand Down

0 comments on commit 8614188

Please sign in to comment.