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

Macroexpansion of @with_kw argument #154

Open
jkosata opened this issue Aug 21, 2023 · 1 comment · May be fixed by #155
Open

Macroexpansion of @with_kw argument #154

jkosata opened this issue Aug 21, 2023 · 1 comment · May be fixed by #155

Comments

@jkosata
Copy link

jkosata commented Aug 21, 2023

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

@jkosata jkosata linked a pull request Aug 24, 2023 that will close this issue
@jkosata
Copy link
Author

jkosata commented Aug 24, 2023

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:/jkosata/DefaultFields.jl

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.

1 participant