macros are now checked to not produce cyclic ASTs
This commit is contained in:
parent
6656f0d713
commit
4ec39b6a8f
2 changed files with 13 additions and 2 deletions
|
|
@ -237,6 +237,14 @@ when false:
|
|||
result.handleIsOperator = proc (n: PNode): PNode =
|
||||
result = isOpImpl(c, n)
|
||||
|
||||
proc hasCycle(n: PNode): bool =
|
||||
incl n.flags, nfNone
|
||||
for i in 0..<safeLen(n):
|
||||
if nfNone in n[i].flags or hasCycle(n[i]):
|
||||
result = true
|
||||
break
|
||||
excl n.flags, nfNone
|
||||
|
||||
proc fixupTypeAfterEval(c: PContext, evaluated, eOrig: PNode): PNode =
|
||||
# recompute the types as 'eval' isn't guaranteed to construct types nor
|
||||
# that the types are sound:
|
||||
|
|
@ -246,7 +254,11 @@ proc fixupTypeAfterEval(c: PContext, evaluated, eOrig: PNode): PNode =
|
|||
else:
|
||||
result = evaluated
|
||||
let expectedType = eOrig.typ.skipTypes({tyStatic})
|
||||
semmacrosanity.annotateType(result, expectedType)
|
||||
if hasCycle(result):
|
||||
globalError(eOrig.info, "the resulting AST is cyclic and cannot be processed further")
|
||||
result = errorNode(c, eOrig)
|
||||
else:
|
||||
semmacrosanity.annotateType(result, expectedType)
|
||||
else:
|
||||
result = semExprWithType(c, evaluated)
|
||||
#result = fitNode(c, e.typ, result) inlined with special case:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue