Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after upgrade to Julia 1.1.1 #75

Closed
janlisse opened this issue Aug 13, 2019 · 2 comments
Closed

Error after upgrade to Julia 1.1.1 #75

janlisse opened this issue Aug 13, 2019 · 2 comments

Comments

@janlisse
Copy link

janlisse commented Aug 13, 2019

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

@jw3126
Copy link
Owner

jw3126 commented Aug 15, 2019

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.

@jw3126
Copy link
Owner

jw3126 commented Feb 4, 2020

We added this functionality in new Setfield versions again.

@jw3126 jw3126 closed this as completed Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants