MacroTools.jl
MacroTools.jl copied to clipboard
Splitdef errors on anonymous function with a single varargs argument
splitdef fails with an assertion on an anonymous function with a single varargs argument:
julia> splitdef(Meta.parse(" (args...) -> 0 "))
ERROR: ArgumentError: Not a function definition: :(args...->begin
#= none:1 =#
0
end)
Stacktrace:
[1] splitdef(fdef::Expr)
@ MacroTools ~/.julia/packages/MacroTools/PP9IQ/src/utils.jl:317
Either adding another argument or using the long form of the definition is fine:
julia> splitdef(Meta.parse(" (x, args...) -> 0 "))
Dict{Symbol, Any} with 4 entries:
:args => Any[:x, :(args...)]
:body => quote…
:kwargs => Any[]
:whereparams => ()
julia> splitdef(Meta.parse(" function f(args...) 0 end "))
Dict{Symbol, Any} with 5 entries:
:name => :f
:args => Any[:(args...)]
:kwargs => Any[]
:body => quote…
:whereparams => ()
PR welcome!