# Problem with static\_unpack

**URL:** <https://discourse.julialang.org/t/problem-with-static-unpack/115320>\
**Category:** General Usage\
**Tags:** componentarrays\
**Created:** [June 7, 2024, 10:58am UTC](https://discourse.julialang.org/t/problem-with-static-unpack/115320 "2024-06-07T10:58:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrea\_Pagnani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrea_pagnani/32/3136_2.png) [@Andrea\_Pagnani](https://discourse.julialang.org/u/Andrea_Pagnani)\
**Post date:** [June 7, 2024, 10:58am UTC](https://discourse.julialang.org/t/problem-with-static-unpack/115320/1 "2024-06-07T10:58:50Z")

</div>

Dearests,

I found that the very first example for the macro at-static\_unpack of [ComponentArrays](https://docs.sciml.ai/ComponentArrays/stable/static_unpack/) is not working

```julia
julia> x = ComponentArray(a=5, b=[4, 1], c = [1 2; 3 4], d=(e=2, f=[6, 30.0]))
ComponentVector{Float64}(a = 5.0, b = [4.0, 1.0], c = [1.0 2.0; 3.0 4.0], d = (e = 2.0, f = [6.0, 30.0])
julia> @static_unpack a, b, c, d = x
ERROR: MethodError: no method matching (StaticArraysCore.SVector{2})(::SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true})
Stacktrace:
 [1] _maybe_SArray(x::SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}, ::Val{2}, ::FlatAxis)
   @ ComponentArrays ~/.julia/packages/ComponentArrays/pROOT/src/compat/static_arrays.jl:5
 [2] macro expansion
   @ ./abstractarray.jl:0 [inlined]
 [3] static_getproperty(ca::ComponentVector{Float64, Vector{Float64}, Tuple{Axis{…}}}, ::Val{:b})
   @ ComponentArrays ~/.julia/packages/ComponentArrays/pROOT/src/compat/static_arrays.jl:9
 [4] top-level scope
   @ REPL[7]:1
Some type information was truncated. Use `show(err)` to see complete types.

```

Status

```julia
Status `~/SCRA/LEO/Project.toml`
  [b0b7db55] ComponentArrays v0.15.13
  [e41cd558] DCAUtils v1.0.1
  [033835bb] JLD2 v0.4.48
  [429524aa] Optim v1.9.4
  [e88e6eb3] Zygote v0.6.70

```

Versioninfo

```julia
julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (x86_64-apple-darwin22.4.0)
  CPU: 12 × Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
  Threads: 11 on 12 virtual cores
Environment:
  DYLD_LIBRARY_PATH = /Users/pagnani/lib/yeppp-1.0.0/binaries/macosx/x86_64:/usr/local/cuda/lib:/Developer/NVIDIA/CUDA-6.5/lib:
  LD_LIBRARY_PATH = /Users/pagnani/.julia/conda/3/lib/:/opt/local/lib/mariadb/mysql/
  JULIA_NUM_THREADS = 8
  JULIA_EDITOR = xem

```

Thanks  
A

---

<div class="post-metadata">

**Author:** ![JonasWickman](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@JonasWickman](https://discourse.julialang.org/u/JonasWickman)\
**Post date:** [June 7, 2024, 1:24pm UTC](https://discourse.julialang.org/t/problem-with-static-unpack/115320/2 "2024-06-07T13:24:36Z")

</div>

Did you import `StaticArrays`? The following works for me:

```julia
using ComponentArrays
using StaticArrays
x = ComponentVector(a=5, b=[4, 1], c = [1 2; 3 4], d=(e=2, f=[6, 30.0]))
@static_unpack a, b, c, d = x

```

---

<div class="post-metadata">

**Author:** ![Andrea\_Pagnani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrea_pagnani/32/3136_2.png) [@Andrea\_Pagnani](https://discourse.julialang.org/u/Andrea_Pagnani)\
**Post date:** [June 8, 2024, 7:15am UTC](https://discourse.julialang.org/t/problem-with-static-unpack/115320/3 "2024-06-08T07:15:15Z")

</div>

Thanks … It works now
