diff options
Diffstat (limited to 'compiler/transf.nim')
-rw-r--r-- | compiler/transf.nim | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/transf.nim b/compiler/transf.nim index 7ab67873b..dd0d546eb 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -104,9 +104,11 @@ proc transformSons(c: PTransf, n: PNode): PNode = for i in 0..<n.len: result[i] = transform(c, n[i]) -proc newAsgnStmt(c: PTransf, kind: TNodeKind, le: PNode, ri: PNode): PNode = +proc newAsgnStmt(c: PTransf, kind: TNodeKind, le: PNode, ri: PNode; isFirstWrite: bool): PNode = result = newTransNode(kind, ri.info, 2) result[0] = le + if isFirstWrite: + le.flags.incl nfFirstWrite2 result[1] = ri proc transformSymAux(c: PTransf, n: PNode): PNode = @@ -365,9 +367,9 @@ proc transformYield(c: PTransf, n: PNode): PNode = case lhs.kind of nkSym: internalAssert c.graph.config, lhs.sym.kind == skForVar - result = newAsgnStmt(c, nkFastAsgn, lhs, rhs) + result = newAsgnStmt(c, nkFastAsgn, lhs, rhs, false) of nkDotExpr: - result = newAsgnStmt(c, nkAsgn, lhs, rhs) + result = newAsgnStmt(c, nkAsgn, lhs, rhs, false) else: internalAssert c.graph.config, false result = newTransNode(nkStmtList, n.info, 0) @@ -734,7 +736,7 @@ proc transformFor(c: PTransf, n: PNode): PNode = # generate a temporary and produce an assignment statement: var temp = newTemp(c, t, formal.info) addVar(v, temp) - stmtList.add(newAsgnStmt(c, nkFastAsgn, temp, arg)) + stmtList.add(newAsgnStmt(c, nkFastAsgn, temp, arg, true)) idNodeTablePut(newC.mapping, formal, temp) of paVarAsgn: assert(skipTypes(formal.typ, abstractInst).kind in {tyVar}) @@ -744,7 +746,7 @@ proc transformFor(c: PTransf, n: PNode): PNode = # arrays will deep copy here (pretty bad). var temp = newTemp(c, arg.typ, formal.info) addVar(v, temp) - stmtList.add(newAsgnStmt(c, nkFastAsgn, temp, arg)) + stmtList.add(newAsgnStmt(c, nkFastAsgn, temp, arg, true)) idNodeTablePut(newC.mapping, formal, temp) let body = transformBody(c.graph, c.idgen, iter, true) |