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

using Parameters: @unpack does not work #43

Closed
tpapp opened this issue Dec 5, 2017 · 4 comments
Closed

using Parameters: @unpack does not work #43

tpapp opened this issue Dec 5, 2017 · 4 comments

Comments

@tpapp
Copy link
Contributor

tpapp commented Dec 5, 2017

MWE:

module Foo

using Parameters: @unpack

struct Bar
    x
    y
end

function f(bar::Bar)
    @unpack x, y = bar
    x + y
end

end

Foo.f(Foo.Bar(1, 2))

Possibly some tricky escaping issue?

@mauro3
Copy link
Owner

mauro3 commented Dec 5, 2017

This is because:

julia> module A
       using Parameters: @unpack
       @show Parameters
       end
ERROR: UndefVarError: Parameters not defined

but the @unpack expands to

julia> @macroexpand @unpack  x= a                                                                                                                                        
quote                                                                                                                                                                                                                 
     x = Parameters.unpack(##664, Val{:x}())                                                                                                                          
end

I'll need to ponder this a bit, also in light of JuliaLang/julia#23579. Thanks for reporting!

@mauro3
Copy link
Owner

mauro3 commented Dec 5, 2017

Ok, this is my sloppy handling of escaping coming to haunt me... I should probably just do it properly.

@mauro3 mauro3 closed this as completed in b3ba90a Dec 5, 2017
@mauro3
Copy link
Owner

mauro3 commented Dec 5, 2017

I'll tag a new release once CI is through.

@tpapp
Copy link
Contributor Author

tpapp commented Dec 5, 2017

Thanks for the amazingly quick fix, I PR'd some unit tests.

mauro3 pushed a commit that referenced this issue Dec 5, 2017
For catching bugs like #43.
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