diff options
author | Arne Döring <arne.doering@gmx.net> | 2020-04-07 14:42:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-07 14:42:59 +0200 |
commit | 37692baf49370d096e0d9ac2c8bf51ed7bd8cf8a (patch) | |
tree | 7ad23f49b978318539fad98f0f96e54cbe833568 /compiler/transf.nim | |
parent | 92c4aad2059a350e95bc7a64932873b41b085976 (diff) | |
download | Nim-37692baf49370d096e0d9ac2c8bf51ed7bd8cf8a.tar.gz |
fix #13739 (#13742)
Diffstat (limited to 'compiler/transf.nim')
-rw-r--r-- | compiler/transf.nim | 9 |
1 files changed, 4 insertions, 5 deletions
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) |