mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 04:02:41 +00:00
15 lines
305 B
Nim
15 lines
305 B
Nim
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'
|
|
|