Following the IRC discussion, I had the hope that using a second macro may
help. But while "genVar("X")" does indeed work, all tries to get it working
with t("X") fails...
import macros
macro genVar(c: string): typed =
result = newNimNode(nnkStmtList)
var
#section = newNimNode(nnkConstSection)
section = newNimNode(nnkVarSection)
constDef = newNimNode(nnkIdentDefs)
constDef.add(newIdentNode("myvar"))
constDef.add(newEmptyNode())
constDef.add(newIdentNode("C" & $c))
section.add(constDef)
result.add(section)
const CX = 7
macro t(s: string): typed =
var hhh = "X"
#genVar("X")
genVar($s)
echo myVar + 1
t("X")