summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2021-01-01 13:55:22 -0800
committerGitHub <noreply@github.com>2021-01-01 22:55:22 +0100
commit0d0e43469f060818ec09d74de5b0bb7ded891898 (patch)
tree7e570f3554302ad90231ec36d12c39c9fc5771c8 /compiler
parent505d04389ad5c83b50001e3108d89fcdec9c462f (diff)
downloadNim-0d0e43469f060818ec09d74de5b0bb7ded891898.tar.gz
fix #14340 (#16386)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgexprs.nim4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index 45044e0ff..53b2832f0 100644
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -3094,7 +3094,9 @@ proc genBracedInit(p: BProc, n: PNode; isConst: bool; optionalType: PType): Rope
       else:
         result = genConstSeq(p, n, typ, isConst)
     of tyProc:
-      if typ.callConv == ccClosure and n.len > 1 and n[1].kind == nkNilLit:
+      if typ.callConv == ccClosure and n.safeLen > 1 and n[1].kind == nkNilLit:
+        # n.kind could be: nkClosure, nkTupleConstr and maybe others; `n.safeLen`
+        # guards against the case of `nkSym`, refs bug #14340.
         # Conversion: nimcall -> closure.
         # this hack fixes issue that nkNilLit is expanded to {NIM_NIL,NIM_NIL}
         # this behaviour is needed since closure_var = nil must be