MacroTools.jl icon indicating copy to clipboard operation
MacroTools.jl copied to clipboard

Splitdef errors on anonymous function with a single varargs argument

Open julbinb opened this issue 3 years ago • 1 comments

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 => ()

julbinb avatar May 29 '22 02:05 julbinb

PR welcome!

cstjean avatar Jun 02 '22 02:06 cstjean