diff options
author | flywind <43030857+xflywind@users.noreply.github.com> | 2020-10-30 16:59:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-30 09:59:56 +0100 |
commit | 1725db9295b037ac410f0e6d48952c01218aee89 (patch) | |
tree | e00f7c9e33cc6e921e8e0e2fef9805a09151ab1e /tests/template/tshadow.nim | |
parent | 3028c1be82a04c0271fcb98396f28ebc62775b3a (diff) | |
download | Nim-1725db9295b037ac410f0e6d48952c01218aee89.tar.gz |
closes #7374 (#15781)
* add testcase for #7374 * minor * fix test
Diffstat (limited to 'tests/template/tshadow.nim')
-rw-r--r-- | tests/template/tshadow.nim | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/template/tshadow.nim b/tests/template/tshadow.nim new file mode 100644 index 000000000..a4de71592 --- /dev/null +++ b/tests/template/tshadow.nim @@ -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 |