summary refs log tree commit diff stats
path: root/compiler/cgen.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-09-27 19:25:00 +0200
committerGitHub <noreply@github.com>2021-09-27 19:25:00 +0200
commitcdf9ac675b4348a7b5239186637c54920bb92619 (patch)
treed8c179d8625481c4b25ab13b3d1d2472a783441e /compiler/cgen.nim
parent5325a366e79b6e34fcd2b2dfe675897212f8ca2d (diff)
downloadNim-cdf9ac675b4348a7b5239186637c54920bb92619.tar.gz
this ensures libp2p continues to compile [backport] (#18908)
Diffstat (limited to 'compiler/cgen.nim')
-rw-r--r--compiler/cgen.nim11
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index a06a87172..43410dc60 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -855,10 +855,15 @@ proc closureSetup(p: BProc, prc: PSym) =
             [rdLoc(env.loc), getTypeDesc(p.module, env.typ)])
 
 proc containsResult(n: PNode): bool =
-  if n.kind == nkSym and n.sym.kind == skResult:
-    result = true
+  result = false
+  case n.kind
+  of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit, nkFormalParams:
+    discard
+  of nkSym:
+    if n.sym.kind == skResult:
+      result = true
   else:
-    for i in 0..<n.safeLen:
+    for i in 0..<n.len:
       if containsResult(n[i]): return true
 
 const harmless = {nkConstSection, nkTypeSection, nkEmpty, nkCommentStmt, nkTemplateDef,