JuliaArrays / JuliaArrays/StructArrays.jl

construct empty vector with `StructVector{Foo1}()`

Open
#183 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
402
Forks
49
PR merge metrics
No merged PRs in 30d

Description

julia> struct Foo1
           x::Int
           y::Int
       end

julia> Vector{Foo1}()
Foo1[]

julia> StructVector{Foo1}()
ERROR: type NamedTuple has no field x
Stacktrace:
 [1] (::Base.var"#164#167"{(:x, :y), NamedTuple{(), Tuple{}}})(n::Int64)
   @ Base ./none:0
 [2] iterate
   @ ./generator.jl:47 [inlined]
 [3] (NamedTuple{(:x, :y), T} where T<:Tuple)(nt::NamedTuple{(), Tuple{}})
   @ Base ./namedtuple.jl:99
 [4] (StructArray{Foo1, N, C, I} where {N, C<:Union{Tuple, NamedTuple}, I})(c::NamedTuple{(), Tuple{}})
   @ StructArrays ~/repos/StructArrays.jl/src/structarray.jl:92
 [5] #_#5
   @ ~/repos/StructArrays.jl/src/structarray.jl:100 [inlined]
 [6] StructArray
   @ ~/repos/StructArrays.jl/src/structarray.jl:100 [inlined]
 [7] #_#7
   @ ~/repos/StructArrays.jl/src/structarray.jl:109 [inlined]
 [8] (StructVector{Foo1, C, I} where {C<:Union{Tuple, NamedTuple}, I})()
   @ StructArrays ~/repos/StructArrays.jl/src/structarray.jl:109
 [9] top-level scope
   @ REPL[56]:1

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

Reproduce the empty-construction example in Julia, then inspect src/structarray.jl around lines 92, 100, and 109 where StructVector delegates to StructArray. Confirm that the completed behavior is an empty StructVector{Foo1}() without the NamedTuple field error, matching Vector{Foo1}().

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.