This works.
import macros
import typetraits
macro t1() : untyped =
return nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
t1()
Run
But if I add:
macro t2(): untyped =
result = t1()
#t2()
Run
It breaks with the error message:
Error: expression 'discard' has no type (or is ambiguous).
Why can't I pass the result of one macro to another?
I have a feeling I'm missing something fundamental here about how macros
work.
Even stranger if I comment out t1 and add discard.
macro t1() : untyped =
discard
#return nnkStmtList.newTree(
# nnkDiscardStmt.newTree(
# newEmptyNode()
# )
#)
Run
It gives the error not unused.