How to pass name of macro argument into result struct parameter

Hello, please help to pass name of macro argument into result struct parameter

struct Foo{x} end

macro foo(x)
    return esc(:($x = Foo{QuoteNode($x)}))  # ???
end

@macroexpand @foo x  # need  - > # x = Foo{:x} 

x = 2

# but i get error:
@foo x 
ERROR: TypeError: in Type, in parameter, expected Type, got a value of type QuoteNode
macro foo(x)
    xs = QuoteNode(x)
    return esc(:($x = Foo{$xs}))
end
1 Like