diff --git a/base/array.jl b/base/array.jl index 5dd482215d192..3811e717211c3 100644 --- a/base/array.jl +++ b/base/array.jl @@ -696,7 +696,8 @@ end function setindex_widen_up_to(dest::AbstractArray{T}, el, i) where T @_inline_meta new = similar(dest, promote_typejoin(T, typeof(el))) - copyto!(new, firstindex(new), dest, firstindex(dest), i-1) + f = first(LinearIndices(dest)) + copyto!(new, first(LinearIndices(new)), dest, f, i-f) @inbounds new[i] = el return new end diff --git a/test/offsetarray.jl b/test/offsetarray.jl index fb6cbd4913305..838bdb3657b9d 100644 --- a/test/offsetarray.jl +++ b/test/offsetarray.jl @@ -332,6 +332,13 @@ am = map(identity, a) @test isa(am, OffsetArray) @test am == a +# https://github.com/JuliaArrays/OffsetArrays.jl/issues/106 +@test isequal(map(!, OffsetArray([true,missing],2)), OffsetArray([false, missing], 2)) +@test isequal(map(!, OffsetArray([true missing; false true], 2, -1)), OffsetArray([false missing; true false], 2, -1)) +P = view([true missing; false true; true false], 1:2:3, :) +@test IndexStyle(P) === IndexCartesian() +@test isequal(map(!, OffsetArray(P, 2, -1)), OffsetArray(map(!, P), 2, -1)) + # dropdims a0 = rand(1,1,8,8,1) a = OffsetArray(a0, (-1,2,3,4,5))