Hello. I tried to represent int to string inside a macros:
import macros
macro initNui(a:int): typed =
result = parseStmt("const b=" & $a)
initNui(1)
but I had compilcation error:
unhandled exception: false Invalid node kind nnkIntLit for macros.`$`
What I'm doing wrong? How I can to get string representation of int without $ operator?add static to the type
import macros
macro initNui(a: static[int]): typed =
result = parseStmt("const b = " & $a)
initNui 1
or you can use intVal, strVal, etc on literal nodes
import macros
macro initNui(a:int): typed =
result = parseStmt("const b=" & $a.intVal)
initNui(1)