Files
Nim/tests/template/tshadow.nim
flywind daba6d935f closes #7374 (#15781)
* add testcase for #7374

* minor

* fix test

(cherry picked from commit 1725db9295)
2020-11-05 09:09:09 +01:00

30 lines
522 B
Nim

discard """
output: '''fish
fish'''
"""
import macros
block:
template init(initHook: proc(s: string)) =
proc dostuff =
var s = "fish"
initHook(s)
dostuff()
init do(s: string):
echo s
block:
macro init(initHook: proc(s: string)) =
result = newStmtList(
newProc(name = ident("dostuff"), body = newStmtList(
newVarStmt(ident("s"), newStrLitNode("fish")),
newCall(initHook, ident("s"))
)),
newCall("dostuff")
)
init proc(s: string) =
echo s