summary refs log tree commit diff stats
path: root/tests/template/ttempl2.nim
blob: 142bbb8c7139a7ad40a400ca1244ae483a691026 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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'