jw3126 / Setfield.jl

Update deeply nested immutable structs.
Other
167 stars 17 forks source link

Setting an `SMatrix` via a `CartesianIndex` fails #169

Closed eschnett closed 2 years ago

eschnett commented 2 years ago

This fails:

julia> A = zero(SMatrix{2,2,Float64})
julia> @set A[CartesianIndex(1,1)] = 4
ERROR: MethodError: no method matching setindex(::SMatrix{2, 2, Float64, 4}, ::Int64, ::CartesianIndex{2})
Closest candidates are:
  setindex(::CartesianIndex, ::Any, ::Any) at multidimensional.jl:100
  setindex(::StaticArray, ::Any, ::Int64) at ~/.julia/packages/StaticArrays/58yy1/src/deque.jl:185
  setindex(::StaticArray, ::Any, ::Int64...) at ~/.julia/packages/StaticArrays/58yy1/src/deque.jl:198
jw3126 commented 2 years ago

Thanks for reporting! I believe this is more a StaticArrays than a Setfield issue. I think the problem would be best solved by adding a appropriate Base.setindex methods in the StaticArrays package?

eschnett commented 2 years ago

Thanks for the pointer. I reported it there https://github.com/JuliaArrays/StaticArrays.jl/issues/1033 .