summary refs log blame commit diff stats
path: root/tests/template/ttempl2.nim
blob: eb67bea0c591267f6ef03aef37b1205ea2af8d63 (plain) (tree)
1
2
3
4
5
6
7
8
9
           
                                          

                     
   
                                                                         
          

                                                                            
                     
        






                                             
discard """
  errormsg: "undeclared identifier: \'b\'"
  file: "ttempl2.nim"
  line: 18
"""
template declareInScope(x: untyped, t: typeDesc): untyped {.immediate.} =
  var x: t

template declareInNewScope(x: untyped, t: typeDesc): untyped {.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'