Hi,
I’m trying to write a macro that takes a proc and extracts its type signature -
used to create another proc with a modified signature. Simplified version of my
attempt so far:
proc parseStmts*(stmts: NimNode): NimNode =
return stmts[0][2]
macro getTheType*(stmts: untyped) =
echo stmts.parseStmts().getType().treeRepr()
Run
Which is meant to be called like this:
proc f(x: string): int = 2
getTheType:
"my proc" -> f
Run
This fails with the error `node has no type`. I wonder whether this is because
the ident for the proc is unbound within the macro. If that’s the case, how can
I bind it?