From 37692baf49370d096e0d9ac2c8bf51ed7bd8cf8a Mon Sep 17 00:00:00 2001 From: Arne Döring Date: Tue, 7 Apr 2020 14:42:59 +0200 Subject: fix #13739 (#13742) --- compiler/transf.nim | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'compiler/transf.nim') diff --git a/compiler/transf.nim b/compiler/transf.nim index 18d9b9130..cbf904255 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -560,8 +560,8 @@ proc putArgInto(arg: PNode, formal: PType): TPutArgInto = of nkBracket: return paFastAsgnTakeTypeFromArg else: - return paDirectMapping # XXX really correct? - # what if ``arg`` has side-effects? + # XXX incorrect, causes #13417 when `arg` has side effects. + return paDirectMapping case arg.kind of nkEmpty..nkNilLit: result = paDirectMapping @@ -671,9 +671,8 @@ proc transformFor(c: PTransf, n: PNode): PNode = idNodeTablePut(newC.mapping, formal, arg) # XXX BUG still not correct if the arg has a side effect! of paComplexOpenarray: - let typ = newType(tySequence, formal.owner) - addSonSkipIntLit(typ, formal.typ[0]) - var temp = newTemp(c, typ, formal.info) + # 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)) idNodeTablePut(newC.mapping, formal, temp) -- cgit 1.4.1-2-gfad0