diff --git a/compiler/evals.nim b/compiler/evals.nim index 66b8de3d0d..968170e85e 100644 --- a/compiler/evals.nim +++ b/compiler/evals.nim @@ -295,8 +295,9 @@ proc evalVar(c: PEvalContext, n: PNode): PNode = # XXX var (x, y) = z support? #assert(a.sons[0].kind == nkSym) can happen for transformed vars if a.sons[2].kind != nkEmpty: - # XXX copyTree could be avoided in some cases - result = evalAux(c, a.sons[2], {}).copyTree + result = evalAux(c, a.sons[2], {}) + if result.kind in {nkType..nkNilLit}: + result = result.copyNode if isSpecial(result): return else: result = getNullValue(a.sons[0].typ, a.sons[0].info) diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 6f4d75b9b5..4598fa9ea9 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -333,9 +333,11 @@ proc nestList*(theProc: TNimrodIdent, ## ``[a, b, c]`` is transformed into ``theProc(a, theProc(c, d))``. var L = x.len result = newCall(theProc, x[L-2], x[L-1]) - var a = result for i in countdown(L-3, 0): - a = newCall(theProc, x[i], copyNimTree(a)) + # XXX the 'copyNimTree' here is necessary due to a bug in the evaluation + # engine that would otherwise create an endless loop here. :-( + # This could easily user code and so should be fixed in evals.nim somehow. + result = newCall(theProc, x[i], copyNimTree(result)) proc treeRepr*(n: PNimrodNode): string {.compileTime.} = ## Convert the AST `n` to a human-readable tree-like string.