Skip to content

Possible breakage in 1.6.0-rc2 and nightly in evaluating CartesianIndices for OffsetArrays with BigInt parent ranges #40035

Closed
@jishnub

Description

@jishnub

Unfortunately there's a bug on master in OffsetArrays currently, so this PR is necessary to see the issue:

on 1.5.4:

julia> using OffsetArrays

julia> a = OffsetArray(big(1):big(2), 0);

julia> CartesianIndices(a)
2-element CartesianIndices{1,Tuple{OffsetArrays.IdOffsetRange{Int64,Base.OneTo{Int64}}}} with indices 1:2:
 CartesianIndex(1,)
 CartesianIndex(2,)

on 1.6.0-rc2 and nightly:

julia> CartesianIndices(a)
ERROR: MethodError: no method matching OrdinalRange{Int64, Int64}(::OffsetArrays.IdOffsetRange{BigInt, Base.OneTo{BigInt}})
Closest candidates are:
  OrdinalRange{T1, T2}(::AbstractUnitRange{T1}) where {T1, T2<:Integer} at range.jl:1133
  OrdinalRange{T1, T2}(::StepRange) where {T1, T2<:Integer} at range.jl:1132
  OrdinalRange{T1, T2}(::UnitRange) where {T1, T2<:Integer} at range.jl:1134
  ...
Stacktrace:
 [1] convert(#unused#::Type{OrdinalRange{Int64, Int64}}, r::OffsetArrays.IdOffsetRange{BigInt, Base.OneTo{BigInt}})
   @ Base ./range.jl:215
 [2] (::Base.IteratorsMD.var"#7#8")(r::OffsetArrays.IdOffsetRange{BigInt, Base.OneTo{BigInt}})
   @ Base.IteratorsMD ./multidimensional.jl:271
 [3] map
   @ ./tuple.jl:213 [inlined]
 [4] CartesianIndices(inds::Tuple{OffsetArrays.IdOffsetRange{BigInt, Base.OneTo{BigInt}}})
   @ Base.IteratorsMD ./multidimensional.jl:271
 [5] CartesianIndices(A::OffsetVector{BigInt, UnitRange{BigInt}})
   @ Base.IteratorsMD ./multidimensional.jl:279
 [6] top-level scope
   @ REPL[4]:1

julia> VERSION
v"1.7.0-DEV.707"

This is due to a missing method for the IdOffsetRange axis type defined in OffsetArrays, but this conversion is not used in 1.5.4. The conversion carried out by CartesianIndices appears to have changed from an AbstractUnitRange{Int} in 1.5.4 to an OrdinalRange{Int,Int} in 1.6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions