mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-27 17:53:58 +00:00
added #903 to the test suite
This commit is contained in:
@@ -12,13 +12,13 @@ import macros, tables
|
||||
var ZOOT{.compileTime.} = initTable[int, int](2)
|
||||
var iii {.compiletime.} = 1
|
||||
|
||||
macro x:stmt=
|
||||
macro zoo:stmt=
|
||||
zoot[iii] = iii*2
|
||||
inc iii
|
||||
echo iii
|
||||
|
||||
x
|
||||
x
|
||||
zoo
|
||||
zoo
|
||||
|
||||
|
||||
macro tupleUnpack: stmt =
|
||||
@@ -27,3 +27,24 @@ macro tupleUnpack: stmt =
|
||||
|
||||
tupleUnpack
|
||||
|
||||
# bug #903
|
||||
|
||||
import strtabs
|
||||
|
||||
var x {.compileTime.}: PStringTable
|
||||
|
||||
macro addStuff(stuff, body: expr): stmt {.immediate.} =
|
||||
result = newNimNode(nnkStmtList)
|
||||
|
||||
if x.isNil:
|
||||
x = newStringTable(modeStyleInsensitive)
|
||||
x[$stuff] = ""
|
||||
|
||||
macro dump(): stmt =
|
||||
result = newNimNode(nnkStmtList)
|
||||
for y in x.keys: echo "Got ", y
|
||||
|
||||
addStuff("Hey"): echo "Hey"
|
||||
addStuff("Hi"): echo "Hi"
|
||||
dump()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user