diff options
Diffstat (limited to 'tests/accept/run')
-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() + |