Indexing a StructVector with an MVector fails

Why does indexing a StructVector with an MVector fail? E.g., I have

meas_idx

 7-element MVector{7, Int64} with indices SOneTo(7):
  809
  267
 1721
 1165
  643
  716
 1808

and


pc[meas_idx]
ArgumentError: invalid index: StaticArrays.StaticIndexing{MVector{7, Int64}}([809, 267, 1721, 1165, 643, 716, 1808]) of type StaticArrays.StaticIndexing{MVector{7, Int64}}

Stacktrace:
  [1] to_index(i::StaticArrays.StaticIndexing{MVector{7, Int64}})
    @ Base ./indices.jl:300
  [2] to_index(A::Vector{SVector{3, Float64}}, i::StaticArrays.StaticIndexing{MVector{7, Int64}})
    @ Base ./indices.jl:277
  [3] to_indices
    @ ./indices.jl:333 [inlined]
  [4] to_indices
    @ ./indices.jl:325 [inlined]
  [5] getindex
    @ ./abstractarray.jl:1241 [inlined]
  [6] (::StructArrays.var"#41#42"{Tuple{StaticArrays.StaticIndexing{MVector{7, Int64}}}})(v::Vector{SVector{3, Float64}})
    @ StructArrays ~/.julia/packages/StructArrays/wkp4X/src/structarray.jl:358
  [7] map
    @ ./tuple.jl:222 [inlined]
  [8] map(::Function, ::NamedTuple{(:first, :second), Tuple{Vector{SVector{3, Float64}}, Vector{SVector{3, Float64}}}})
    @ Base ./namedtuple.jl:219
  [9] _getindex
    @ ~/.julia/packages/StructArrays/wkp4X/src/structarray.jl:358 [inlined]
 [10] getindex(x::StructArrays.StructVector{NamedTuple{(:first, :second), Tuple{SVector{3, Float64}, SVector{3, Float64}}}, NamedTuple{(:first, :second), Tuple{Vector{SVector{3, Float64}}, Vector{SVector{3, Float64}}}}, Int64}, I::MVector{7, Int64})
    @ StructArrays ~/.julia/packages/StructArrays/wkp4X/src/structarray.jl:348
 [11] top-level scope
    @ In[60]:1
 [12] eval
    @ ./boot.jl:368 [inlined]
 [13] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:1428

but if I do

 idx = zeros(Int64,7)

 7-element Vector{Int64}:
 0
 0
 0
 0
 0
 0
 0

 idx.=meas_idx

 7-element Vector{Int64}:
  809
  267
 1721
 1165
  643
  716
 1808

pc[idx]

 7-element StructArray(::Vector{SVector{3, Float64}}, ::Vector{SVector{3, Float64}}) with eltype NamedTuple{(:first, :second), Tuple{SVector{3, Float64}, SVector{3, Float64}}}:
 (first = [258.845273716783, 487.8977904159955, 1.0], second = [157.75229949765156, 595.5183920659432, 1.0])
 (first = [289.51900905492465, 393.4757347730604, 1.0], second = [308.550992447045, 617.3501755260837, 1.0])
 (first = [362.3296991292668, 332.0351721512725, 1.0], second = [579.3702766788141, 107.44831106083338, 1.0])
 (first = [212.17086720049917, 384.978545513196, 1.0], second = [72.76975409415482, 325.9100048752102, 1.0])
 (first = [434.6340517380251, 302.23356061671365, 1.0], second = [817.7310106439842, -96.58932611310641, 1.0])
 (first = [129.05937348135052, 179.94913799787562, 1.0], second = [32.05033362166862, 171.35102226173754, 1.0])
 (first = [217.74765338653387, 483.1258600918965, 1.0], second = [58.753844157796244, 847.0375594100266, 1.0])

it works, but why can’t MVector be used for indexing?

It should work, looks like a bug. Please file an issue with StaticArrays.jl

Is the problem with StaticArrays or StructArrays?

With static arrays, since they define how indexing with static vectors should work

ok. done. thanks!