* add testcase for #7374

* minor

* fix test
This commit is contained in:
flywind 2020-10-30 16:59:56 +08:00 • committed by GitHub
commit 1725db9295
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,29 @@
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