ttempl2.nim 403 B

12345678910111213141516171819
  1. discard """
  2. errormsg: "undeclared identifier: \'b\'"
  3. file: "ttempl2.nim"
  4. line: 18
  5. """
  6. template declareInScope(x: untyped, t: typeDesc): untyped =
  7. var x: t
  8. template declareInNewScope(x: untyped, t: typeDesc): untyped =
  9. # open a new scope:
  10. block:
  11. var x: t
  12. declareInScope(a, int)
  13. a = 42 # works, `a` is known here
  14. declareInNewScope(b, int)
  15. b = 42 #ERROR_MSG undeclared identifier: 'b'