summary refs log blame commit diff stats
path: root/tests/reject/ttempl2.nim
blob: fba988f957c277118a2e488e1cfb705c22d797ae (plain) (tree)
1
2
3
4
5




                                          













                                                         

 
discard """
  file: "ttempl2.nim"
  line: 18
  errormsg: "undeclared identifier: \'b\'"
"""
template declareInScope(x: expr, t: typeDesc): stmt = 
  var x: t
  
template declareInNewScope(x: expr, t: typeDesc): stmt = 
  # 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'