Skip to content

Commit 5af0445

Browse files
committed
fix A[]=x for Array and BitArray
fix gen_cartesian_map in the case of ranges===()
1 parent 8e74531 commit 5af0445

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

base/abstractarray.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ end
317317
## specifies what it wants to do before and after each loop.
318318
## If genbodies creates an array it must of length N.
319319
function gen_cartesian_map(cache, genbodies, ranges, exargnames, exargs...)
320+
if ranges === ()
321+
ranges = (1,)
322+
end
320323
N = length(ranges)
321324
if !haskey(cache,N)
322325
if isdefined(genbodies,:code)

base/array.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ getindex{T<:Real}(A::Matrix, I::AbstractVector{T}, J::AbstractVector{Bool}) = A[
387387
getindex{T<:Real}(A::Matrix, I::AbstractVector{Bool}, J::AbstractVector{T}) = A[find(I),J]
388388

389389
## Indexing: setindex! ##
390-
setindex!{T}(A::Array{T,0}, x) = arrayset(A, convert(T,x), 1)
390+
setindex!{T}(A::Array{T}, x) = arrayset(A, convert(T,x), 1)
391391

392392
setindex!(A::Array{Any}, x::ANY, i::Real) = arrayset(A, x, to_index(i))
393393

base/bitarray.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ end
302302

303303
getindex(B::BitArray, i::Real) = getindex(B, to_index(i))
304304

305+
getindex(B::BitArray) = getindex(B, 1)
306+
305307
# 0d bitarray
306308
getindex(B::BitArray{0}) = getindex_unchecked(B.chunks, 1)
307309

@@ -476,6 +478,8 @@ function setindex!(B::BitArray, x::Bool, i::Int)
476478
return B
477479
end
478480

481+
setindex!(B::BitArray, x) = setindex!(B, x, 1)
482+
479483
setindex!(B::BitArray, x, i::Real) = setindex!(B, convert(Bool,x), to_index(i))
480484

481485
setindex!(B::BitArray, x, i0::Real, i1::Real) =

0 commit comments

Comments
 (0)