OffsetArrays.jl icon indicating copy to clipboard operation
OffsetArrays.jl copied to clipboard

Breaking change in Base.vect on nightly if the elements have offset axes

Open jishnub opened this issue 3 years ago • 0 comments

See https://github.com/JuliaLang/julia/issues/44939.

The issue is that, because of more aggressive type promotion for arrays on nightly,

ulia> [ones(2), ones(2:3)]
ERROR: DimensionMismatch: axes must agree, got (Base.OneTo(2),) and (OffsetArrays.IdOffsetRange(values=2:3, indices=2:3),)
Stacktrace:
 [1] (::Base.var"#checkaxs#139")(axd::Tuple{Base.OneTo{Int64}}, axs::Tuple{OffsetArrays.IdOffsetRange{Int64, Base.OneTo{Int64}}})
   @ Base ./abstractarray.jl:1123
 [2] copyto_axcheck!(dest::Vector{Float64}, src::OffsetVector{Float64, Vector{Float64}})
   @ Base ./abstractarray.jl:1125
 [3] Array
   @ ./array.jl:625 [inlined]
 [4] convert
   @ ./array.jl:616 [inlined]
 [5] setindex!
   @ ./array.jl:961 [inlined]
 [6] copyto!(dest::Vector{Vector{Float64}}, src::Tuple{Vector{Float64}, OffsetVector{Float64, Vector{Float64}}})
   @ Base ./abstractarray.jl:909
 [7] vect(::Vector{Float64}, ::Vararg{Any})
   @ Base ./array.jl:147
 [8] top-level scope
   @ REPL[4]:1

whereas, on 1.7 and 1.8.0-beta3,

julia> [ones(2), ones(2:3)]
2-element Vector{AbstractVector{Float64}}:
 [1.0, 1.0]
 [1.0, 1.0]

It was suggested that the fix should go here, by defining appropriate promotion rules.

jishnub avatar Apr 14 '22 07:04 jishnub