diff options
Diffstat (limited to 'tests/template/ttempl2.nim')
-rw-r--r-- | tests/template/ttempl2.nim | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/template/ttempl2.nim b/tests/template/ttempl2.nim new file mode 100644 index 000000000..142bbb8c7 --- /dev/null +++ b/tests/template/ttempl2.nim @@ -0,0 +1,19 @@ +discard """ + file: "ttempl2.nim" + line: 18 + errormsg: "undeclared identifier: \'b\'" +""" +template declareInScope(x: expr, t: typeDesc): stmt {.immediate.} = + var x: t + +template declareInNewScope(x: expr, t: typeDesc): stmt {.immediate.} = + # open a new scope: + block: + var x: t + +declareInScope(a, int) +a = 42 # works, `a` is known here + +declareInNewScope(b, int) +b = 42 #ERROR_MSG undeclared identifier: 'b' + |