diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-08-22 18:31:15 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-08-22 18:31:26 +0200 |
commit | 9c9a7b6520e45cc71f071e82e8306ad276d72258 (patch) | |
tree | d7233d11d8b4f1d05d1078af5702a14839e8f561 /compiler | |
parent | 3fc95ce69e787b988f2f47adb035eabf082822ca (diff) | |
download | Nim-9c9a7b6520e45cc71f071e82e8306ad276d72258.tar.gz |
fixes #3221
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/transf.nim | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/transf.nim b/compiler/transf.nim index d64276cfb..fc400c524 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -474,12 +474,14 @@ proc transformConv(c: PTransf, n: PNode): PTransNode = type TPutArgInto = enum - paDirectMapping, paFastAsgn, paVarAsgn + paDirectMapping, paFastAsgn, paVarAsgn, paComplexOpenarray proc putArgInto(arg: PNode, formal: PType): TPutArgInto = # This analyses how to treat the mapping "formal <-> arg" in an # inline context. if skipTypes(formal, abstractInst).kind in {tyOpenArray, tyVarargs}: + if arg.kind == nkStmtListExpr: + return paComplexOpenarray return paDirectMapping # XXX really correct? # what if ``arg`` has side-effects? case arg.kind @@ -569,6 +571,14 @@ proc transformFor(c: PTransf, n: PNode): PTransNode = assert(skipTypes(formal.typ, abstractInst).kind == tyVar) 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.sons[0]) + var temp = newTemp(c, typ, formal.info) + addVar(v, temp) + add(stmtList, newAsgnStmt(c, temp, arg.PTransNode)) + idNodeTablePut(newC.mapping, formal, temp) + var body = iter.getBody.copyTree pushInfoContext(n.info) # XXX optimize this somehow. But the check "c.inlining" is not correct: |