Expronicon.jl
Expronicon.jl copied to clipboard
function keyword arguments default values are not generated
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.
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
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