mcabbott / mcabbott/AxisKeys.jl

stackoverflow in zero-dimensional indexing

Open
#66 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
154
Forks
31
PR merge metrics
No merged PRs in 30d

Description

Zero-dimensional KeyedArray works mostly fine:

julia> using AxisKeys
julia> ka0 = KeyedArray(fill(123));
julia> ka0[1]
123
julia> size(ka0)
()
julia> ndims(ka0)
0
julia> axiskeys(ka0)
()

However, the corresponding zero-dimensional indexing fails with a StackOverflowError:

julia> ka0[]
ERROR: StackOverflowError:
Stacktrace:
     [1] getindex(A::KeyedArray{Int64, 0, NamedDimsArray{(), Int64, 0, Array{Int64, 0}}, Tuple{}})
       @ AxisKeys ~/.julia/dev/AxisKeys/src/names.jl:83
     [2] getindex(A::KeyedArray{Int64, 0, NamedDimsArray{(), Int64, 0, Array{Int64, 0}}, Tuple{}}; kw::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
       @ AxisKeys ~/.julia/dev/AxisKeys/src/names.jl:85
--- the last 2 lines are repeated 39990 more times ---
 [79983] getindex(A::KeyedArray{Int64, 0, NamedDimsArray{(), Int64, 0, Array{Int64, 0}}, Tuple{}})
       @ AxisKeys ~/.julia/dev/AxisKeys/src/names.jl:83

I'm not familiar with this kind of internals, but looks like a wrong getindex method gets called somehow.

For comparison, 0-d arrays in base julia:

julia> a0 = fill(123)
0-dimensional Array{Int64, 0}:
123
julia> a0[]
123
julia> a0[1]
123

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the getindex methods in src/names.jl around lines 83-85, then reproduce the zero-dimensional KeyedArray example and compare it with base Julia's a0[]. Done means ka0[] returns 123 without recursive dispatch or a StackOverflowError; verify ka0[1] and the existing zero-dimensional behavior still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.