import macros
dumpTree:
type A = enum a, b
macro test(): stmt =
result = newStmtList(
newNimNode(nnkTypeDef).add(
ident("A"),
newEmptyNode(),
newNimNode(nnkEnumTy).add(
newEmptyNode(),
ident("a"),
ident("b"))))
test
echo(a)
echo(A.a)
Which fails with
Error: invalid expression: 'A = enum a, b'
Hi,
I extended your macro with echo treeRepr(result) to see what is missing. An extra newNimNode(nnkTypeSection).add( ... ) is needed.
Peter