Skip to content

Zero-dimensional views of AbstractVectors assume that the parent is 1-indexed #37274

@jishnub

Description

@jishnub

This is the same issue reported in OffsetArrays, but I'm posting it here as I'm not sure if the fix should go into Base. Please close this if it's more appropriate for the fix to be in OffsetArrays.

For a zero-dimensional array a we usually expect a[] == a[1]. However this does not work with zero-D views of OffsetVectors

julia> using OffsetArrays

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

julia> b = @view a[0]
0-dimensional view(OffsetArray(::UnitRange{Int64}, 0:2), 0) with eltype Int64:
1

julia> b[]
1

julia> b[1]
2

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions