This commit is contained in:
Araq
2012-06-21 19:08:39 +02:00
parent 2294c02cc8
commit 4d9a5dc8ff
3 changed files with 16 additions and 10 deletions

View File

@@ -117,6 +117,8 @@ proc semAfterMacroCall(c: PContext, n: PNode, s: PSym): PNode =
proc semMacroExpr(c: PContext, n: PNode, sym: PSym,
semCheck: bool = true): PNode =
markUsed(n, sym)
if sym == c.p.owner:
GlobalError(n.info, errRecursiveDependencyX, sym.name.s)
if c.evalContext == nil:
c.evalContext = newEvalContext(c.module, "", emStatic)
result = evalMacroCall(c.evalContext, n, sym)

View File

@@ -18,13 +18,3 @@ macro test*(a: stmt): stmt =
test:
"hi"
macro dump(n: stmt): stmt =
dump(n)
if kind(n) == nnkNone:
nil
else:
hint($kind(n))
for i in countUp(0, len(n)-1):
nil

View File

@@ -0,0 +1,14 @@
discard """
file: "trecmacro.nim"
line: 8
errormsg: "recursive dependency: 'dump'"
"""
macro dump(n: stmt): stmt =
dump(n)
if kind(n) == nnkNone:
nil
else:
hint($kind(n))
for i in countUp(0, len(n)-1):
nil