diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim index 6c5b721c70..242e9f5cf4 100644 --- a/compiler/ccgcalls.nim +++ b/compiler/ccgcalls.nim @@ -249,7 +249,7 @@ proc openArrayLoc(p: BProc, formalType: PType, n: PNode): Rope = else: internalError(p.config, "openArrayLoc: " & typeToString(a.t)) proc withTmpIfNeeded(p: BProc, a: TLoc, needsTmp: bool): TLoc = - if needsTmp: + if needsTmp and a.lode.typ != nil: var tmp: TLoc getTemp(p, a.lode.typ, tmp, needsInit=false) genAssignment(p, tmp, a, {}) diff --git a/tests/ccgbugs/t2procs.nim b/tests/ccgbugs/t2procs.nim new file mode 100644 index 0000000000..d8b7a2815a --- /dev/null +++ b/tests/ccgbugs/t2procs.nim @@ -0,0 +1,18 @@ +discard """ + output: '''before +1 +before +2''' +""" + +proc fn[T1, T2](a: T1, b: T2) = + a(1) + b(2) + +fn( (proc(x: int) = + echo "before" # example block, can span multiple lines + echo x), + (proc (y: int) = + echo "before" + echo y) +)