mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-02 09:58:01 +00:00
* add testcase for #7374
* minor
* fix test
(cherry picked from commit 1725db9295)
This commit is contained in:
29
tests/template/tshadow.nim
Normal file
29
tests/template/tshadow.nim
Normal 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
|
||||
Reference in New Issue
Block a user