mauro3/Parameters.jl

Macroexpansion of @with_kw argument

jkosata opened this issue · 1 comments

I am experimenting with macros that define a struct. Here's an MWE of my problem:

using Parameters

macro structmacro()
    return quote struct mystruct; myfield::Int; end end
end

@with_kw @structmacro

gives

ERROR: LoadError: @with_kw only supported for types which have at least one field.

Seems that @with_kw does not expand @structmacro into a struct declaration. The solution is probably analogous to #21

Turns out expanding :macrocall and :block expressions in with_kw does the trick here. Submitting a pull request as I need this functionality for https://github.com/jkosata/DefaultFields.jl