From 7101c8ca18bace923d91f44c67ec5beb7e19852f Mon Sep 17 00:00:00 2001 From: Araq Date: Fri, 3 Jan 2020 14:19:18 +0100 Subject: [PATCH] fixes #12956 --- compiler/closureiters.nim | 3 ++- compiler/injectdestructors.nim | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/closureiters.nim b/compiler/closureiters.nim index 94e5086bbefb4..03545e151ae0d 100644 --- a/compiler/closureiters.nim +++ b/compiler/closureiters.nim @@ -838,7 +838,8 @@ proc transformReturnsInTry(ctx: var Ctx, n: PNode): PNode = if n[0].kind != nkEmpty: let asgnTmpResult = newNodeI(nkAsgn, n.info) asgnTmpResult.add(ctx.newTmpResultAccess()) - asgnTmpResult.add(n[0]) + let x = if n[0].kind in {nkAsgn, nkFastAsgn}: n[0][1] else: n[0] + asgnTmpResult.add(x) result.add(asgnTmpResult) result.add(ctx.newNullifyCurExc(n.info)) diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index fad1eb03b9ff8..56f8026d529ac 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -227,7 +227,7 @@ proc genCopy(c: var Con; dest, ri: PNode): PNode = # try to improve the error message here: if c.otherRead == nil: discard isLastRead(ri, c) checkForErrorPragma(c, t, ri, "=") - genCopyNoCheck(c, dest, ri) + result = genCopyNoCheck(c, dest, ri) proc genDestroy(c: Con; dest: PNode): PNode = let t = dest.typ.skipTypes({tyGenericInst, tyAlias, tySink}) @@ -571,6 +571,7 @@ proc p(n: PNode; c: var Con; mode: ProcessMode): PNode = else: if n[0].kind in {nkDotExpr, nkCheckedFieldExpr}: cycleCheck(n, c) + assert n[1].kind notin {nkAsgn, nkFastAsgn} result = moveOrCopy(n[0], n[1], c, isFirstWrite = false) else: result = copyNode(n)