You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It leads to the following stacktrace: ERROR: LoadError: MethodError: no method matching setindex(::Array{Foo,1}, ::Foo, ::Int64) Closest candidates are: setindex(::Tuple, ::Any, ::Integer) at tuple.jl:31 Stacktrace: [1] set at /Users/jan/.julia/packages/Setfield/gMRkV/src/lens.jl:227 [inlined] [2] set(::Array{Foo,1}, ::Setfield.ComposedLens{Setfield.IndexLens{Tuple{Int64}},Setfield.PropertyLens{:a}}, ::Float64) at /Users/jan/.julia/packages/Setfield/gMRkV/src/lens.jl:216 [3] modify(::Setfield._UpdateOp{typeof(*),Float64}, ::Array{Foo,1}, ::Setfield.ComposedLens{Setfield.IndexLens{Tuple{Int64}},Setfield.PropertyLens{:a}}) at /Users/jan/.julia/packages/Setfield/gMRkV/src/lens.jl:87 [4] top-level scope at /Users/jan/.julia/packages/Setfield/gMRkV/src/sugar.jl:119 [5] include at ./boot.jl:326 [inlined] [6] include_relative(::Module, ::String) at ./loading.jl:1038 [7] include(::Module, ::String) at ./sysimg.jl:29 [8] include(::String) at ./client.jl:403 [9] top-level scope at none:0 in expression starting at /Users/jan/projects/julia/PowerDynamics.jl/setfields_error.jl:10
The text was updated successfully, but these errors were encountered:
The ability to use @set on Array was removed a long time ago. You were probably using a very old version of Setfield before? See also #71
Personally I usually use foo = nodes[1]; nodes[1] = @set foo.a *= 0.9 in such cases.
Hi,
after upgrading to Julia 1.1.1 (from 1.1.0) the following code no longer works:
`using Setfield
struct Foo
a
b
end
nodes = [Foo(1,1), Foo(2,2)]
nodes_alt = @set nodes[1].a *= 0.9
`
It leads to the following stacktrace:
ERROR: LoadError: MethodError: no method matching setindex(::Array{Foo,1}, ::Foo, ::Int64) Closest candidates are: setindex(::Tuple, ::Any, ::Integer) at tuple.jl:31 Stacktrace: [1] set at /Users/jan/.julia/packages/Setfield/gMRkV/src/lens.jl:227 [inlined] [2] set(::Array{Foo,1}, ::Setfield.ComposedLens{Setfield.IndexLens{Tuple{Int64}},Setfield.PropertyLens{:a}}, ::Float64) at /Users/jan/.julia/packages/Setfield/gMRkV/src/lens.jl:216 [3] modify(::Setfield._UpdateOp{typeof(*),Float64}, ::Array{Foo,1}, ::Setfield.ComposedLens{Setfield.IndexLens{Tuple{Int64}},Setfield.PropertyLens{:a}}) at /Users/jan/.julia/packages/Setfield/gMRkV/src/lens.jl:87 [4] top-level scope at /Users/jan/.julia/packages/Setfield/gMRkV/src/sugar.jl:119 [5] include at ./boot.jl:326 [inlined] [6] include_relative(::Module, ::String) at ./loading.jl:1038 [7] include(::Module, ::String) at ./sysimg.jl:29 [8] include(::String) at ./client.jl:403 [9] top-level scope at none:0 in expression starting at /Users/jan/projects/julia/PowerDynamics.jl/setfields_error.jl:10
The text was updated successfully, but these errors were encountered: