diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/liftlocals.nim | 12 | ||||
-rw-r--r-- | compiler/transf.nim | 2 |
2 files changed, 8 insertions, 6 deletions
diff --git a/compiler/liftlocals.nim b/compiler/liftlocals.nim index f29a4e106..3610a1486 100644 --- a/compiler/liftlocals.nim +++ b/compiler/liftlocals.nim @@ -52,17 +52,19 @@ proc lookupParam(params, dest: PNode): PSym = if params[i].kind == nkSym and params[i].sym.name.id == dest.ident.id: return params[i].sym -proc liftLocalsIfRequested*(prc: PSym) = +proc liftLocalsIfRequested*(prc: PSym; n: PNode): PNode = let liftDest = getPragmaVal(prc.ast, wLiftLocals) - if liftDest == nil: return + if liftDest == nil: return n let partialParam = lookupParam(prc.typ.n, liftDest) if partialParam.isNil: localError(liftDest.info, "'$1' is not a parameter of '$2'" % [$liftDest, prc.name.s]) - return + return n let objType = partialParam.typ.skipTypes(abstractPtrs) if objType.kind != tyObject or tfPartial notin objType.flags: localError(liftDest.info, "parameter '$1' is not a pointer to a partial object" % $liftDest) - return + return n var c = Ctx(partialParam: partialParam, objType: objType) - liftLocals(prc.ast, bodyPos, c) + let w = newTree(nkStmtList, n) + liftLocals(w, 0, c) + result = w[0] diff --git a/compiler/transf.nim b/compiler/transf.nim index c3bdd4ddc..baf801cbf 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -978,7 +978,7 @@ proc transformBody*(module: PSym, n: PNode, prc: PSym): PNode = liftDefer(c, result) #result = liftLambdas(prc, result) when useEffectSystem: trackProc(prc, result) - liftLocalsIfRequested(prc) + result = liftLocalsIfRequested(prc, result) if c.needsDestroyPass and newDestructors: result = injectDestructorCalls(prc, result) incl(result.flags, nfTransf) |