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

Varargs inside macros swallow keyword arguments #15896

Closed
nalimilan opened this issue Apr 16, 2016 · 2 comments · Fixed by #15913 or #17991
Closed

Varargs inside macros swallow keyword arguments #15896

nalimilan opened this issue Apr 16, 2016 · 2 comments · Fixed by #15913 or #17991

Comments

@nalimilan
Copy link
Member

Macros with complex uses of varargs and keyword arguments can give really weird results. In the following, the keyword argument y shouldn't be passed to g(), nor passed twice to f(), and using , or ; shouldn't make any difference.

julia> macro test(d, x...; y=0)
           esc(:(f(g($d, $(x...)), $(x...); y=$y)))
       end
@test (macro with 1 method)

julia> macroexpand(:(@test(1, 2, 3; y=4)))
:(f(g(1,2,3; y=4),1,2,3; y=0))

julia> macroexpand(:(@test(1, 2, 3, y=4)))
:(f(g(1,2,3,y=4),2,3,y=4; y=0))
@yuyichao
Copy link
Contributor

This is not related to Varargs since I don't think you can pass any kw argument to a macro in general, they are all passed as expressions, i.e. Expr(:kw) and Expr(:parameters).

@nalimilan
Copy link
Member Author

Thanks. Are there any plans to allow passing keyword arguments to macros? I have a case in which it would have been useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants