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

function keyword arguments default values are not generated #17

Open
domluna opened this issue Sep 4, 2021 · 2 comments · May be fixed by #18
Open

function keyword arguments default values are not generated #17

domluna opened this issue Sep 4, 2021 · 2 comments · May be fixed by #18

Comments

@domluna
Copy link

domluna commented Sep 4, 2021

julia> JLFunction(;name="foo", kwargs=[JLKwField(;name=:arg1, default=10)])^C

julia> kw = JLKwField(;name=:arg1, default=10, type=:Int)
arg1::Int

julia> f = JLFunction(;name="foo", kwargs=[kw])
function "foo"(; arg1::Int)
end

julia> codegen_ast(a)
:(arg1::Int)

julia> codegen_ast(f)
:(function ("foo")(; arg1::Int)
  end)

This should be arg1::Int=10. Changing 10 to a Symbol has the same result.

@domluna domluna changed the title Kw args default values are not generated function keyword arguments default values are not generated Sep 4, 2021
@domluna
Copy link
Author

domluna commented Sep 4, 2021

https://github.com/Roger-luo/Expronicon.jl/blob/master/src/codegen.jl#L440-L446

JLKwField needs it's own codegen func, I can make a PR

@Roger-luo
Copy link
Owner

ah thanks! good catch!

the JLKwField was intended to use for JLKwStruct at the beginning, so what actually should be in JLFunction is Expr(:kw, name, default), I should have used JLKwField in JLFunction too, but I was too lazy :P

JLKwField needs it's own codegen func, I can make a PR

Please feel free to open one! I can also help on it

domluna added a commit to domluna/Expronicon.jl that referenced this issue Sep 4, 2021
@domluna domluna linked a pull request Sep 4, 2021 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants