> before the macro substitution. I think it happens _after_ the macro substitution, in which `i` has been _gensym_ 'd. This later caused `i` to be unaccessible with its original name (when `fmt` resolves).
This macro/template thing seems to be some kind of FIFO. And the secret is to use the _symbol_ directly. import strformat import macros macro t1(): untyped = return quote do: var i = 10 echo "i is " & $i proc p1() = t1() when isMainModule: p1() Run