diff options
author | Araq <rumpf_a@web.de> | 2011-10-28 01:38:41 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-10-28 01:38:41 +0200 |
commit | a0a8934a4f089f8a438da280a4c80051ba3607b5 (patch) | |
tree | 7869a80b499d8740d84549ca178d60a7470ba5c2 /tests/accept | |
parent | fe9bb1869d8418e6929e0d3a284b698c690af06e (diff) | |
download | Nim-a0a8934a4f089f8a438da280a4c80051ba3607b5.tar.gz |
eval context for macros lives as long as the current module is compiled
Diffstat (limited to 'tests/accept')
-rw-r--r-- | tests/accept/run/tidgen.nim | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/accept/run/tidgen.nim b/tests/accept/run/tidgen.nim new file mode 100644 index 000000000..68fffbabb --- /dev/null +++ b/tests/accept/run/tidgen.nim @@ -0,0 +1,19 @@ +discard """ + output: "3 4" +""" + +import macros + +# Test compile-time state in same module + +var gid = 3 + +macro genId(invokation: expr): expr = + result = newIntLitNode(gid) + inc gid + +proc Id1(): int = return genId() +proc Id2(): int = return genId() + +echo Id1(), " ", Id2() + |