diff options
Diffstat (limited to 'tests/template/ttempl2.nim')
-rw-r--r-- | tests/template/ttempl2.nim | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/template/ttempl2.nim b/tests/template/ttempl2.nim new file mode 100644 index 000000000..e84e0630b --- /dev/null +++ b/tests/template/ttempl2.nim @@ -0,0 +1,18 @@ +discard """ + errormsg: "undeclared identifier: \'b\'" + file: "ttempl2.nim" + line: 18 +""" +template declareInScope(x: untyped, t: typeDesc): untyped = + var x: t + +template declareInNewScope(x: untyped, t: typeDesc): untyped = + # 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' |