@unpack stopped working
juliohm opened this issue · 1 comments
juliohm commented
julia> using Parameters
julia> @with_kw struct Foo
a
b
c
end
Foo
julia> f = Foo(a=1,b=2,c=3)
Foo
a: Int64 1
b: Int64 2
c: Int64 3
julia> a, b, c = @unpack f
ERROR: LoadError: type Symbol has no field head
Stacktrace:
[1] getproperty(::Symbol, ::Symbol) at ./Base.jl:33
[2] @unpack(::LineNumberNode, ::Module, ::Any) at /home/juliohm/.julia/packages/UnPack/EkESO/src/UnPack.jl:93
in expression starting at REPL[7]:1
Parameters.jl v0.12.1
mauro3 commented
You have to:
julia> @unpack a, b, c = f
Foo
a: Int64 1
b: Int64 2
c: Int64 3
(also note that UnPack.jl is its own package, and that you can also unpack ordinary structs.)