Skip to content

Unpacking optional components throws #500

@ameligrana

Description

@ameligrana

MWE:

julia> using Ark

julia> struct A 
           x::Float64
       end

julia> struct B end

julia> world = World(A, B)
World(entities=0, comp_types=(A, B))

julia> new_entity!(world, (A(1.),))
Entity(2, 0)

julia> q = Query(world, (A,); optional=(B,))
Query((A); optional=(B))

julia> for t in q
           @unpack (entities, a, b) = t
       end
ERROR: MethodError: no method matching unpack(::Nothing)

Closest candidates are:
  unpack(::SubArray)
   @ Ark ~/.julia/dev/Ark/src/fieldsview.jl:24
  unpack(::FieldViews.FieldViewable{T}) where T
   @ Ark ~/.julia/dev/Ark/src/fieldsview.jl:18
  unpack(::Ark._StructArrayView)
   @ Ark ~/.julia/dev/Ark/src/structarray_interface.jl:152

Stacktrace:
 [1] top-level scope
   @ ./REPL[14]:2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions