This commit is contained in:
Timothee Cour 2021-01-01 13:55:22 -08:00 • committed by GitHub
commit 0d0e43469f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View file

@ -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