summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-03-23 09:57:17 +0100
committerGitHub <noreply@github.com>2020-03-23 09:57:17 +0100
commit7ee08b8cf6e98312986c821119e4c779505ed6aa (patch)
tree381ca0078e955bc8bc34701378428c0af5f719ab /compiler
parent0ac9c7bb642aefc18a9ca1a7b58f22aea6cf61ce (diff)
downloadNim-7ee08b8cf6e98312986c821119e4c779505ed6aa.tar.gz
Revert "fix #13417 (#13712)" (#13728)
This reverts commit a5f02cac85281fc2804e910f330f0c11d3c4f77b.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/transf.nim21
1 files changed, 11 insertions, 10 deletions
diff --git a/compiler/transf.nim b/compiler/transf.nim
index 2bd64804e..c1af6c23f 100644
--- a/compiler/transf.nim
+++ b/compiler/transf.nim
@@ -554,14 +554,14 @@ proc putArgInto(arg: PNode, formal: PType): TPutArgInto =
   # inline context.
   if formal.kind == tyTypeDesc: return paDirectMapping
   if skipTypes(formal, abstractInst).kind in {tyOpenArray, tyVarargs}:
-    case arg.skipHidden.kind
+    case arg.kind
+    of nkStmtListExpr:
+      return paComplexOpenarray
     of nkBracket:
       return paFastAsgnTakeTypeFromArg
-    of nkSym:
-      return paDirectMapping
     else:
-      return paComplexOpenarray
-
+      return paDirectMapping    # XXX really correct?
+                                # what if ``arg`` has side-effects?
   case arg.kind
   of nkEmpty..nkNilLit:
     result = paDirectMapping
@@ -569,14 +569,14 @@ proc putArgInto(arg: PNode, formal: PType): TPutArgInto =
     result = putArgInto(arg[0], formal)
   of nkCurly, nkBracket:
     for i in 0..<arg.len:
-      if putArgInto(arg[i], formal) != paDirectMapping:
+      if putArgInto(arg[i], formal) != paDirectMapping: 
         return paFastAsgn
     result = paDirectMapping
   of nkPar, nkTupleConstr, nkObjConstr:
     for i in 0..<arg.len:
       let a = if arg[i].kind == nkExprColonExpr: arg[i][1]
               else: arg[0]
-      if putArgInto(a, formal) != paDirectMapping:
+      if putArgInto(a, formal) != paDirectMapping: 
         return paFastAsgn
     result = paDirectMapping
   else:
@@ -644,7 +644,7 @@ proc transformFor(c: PTransf, n: PNode): PNode =
   # generate access statements for the parameters (unless they are constant)
   pushTransCon(c, newC)
   for i in 1..<call.len:
-    let arg = transform(c, call[i])
+    var arg = transform(c, call[i])
     let ff = skipTypes(iter.typ, abstractInst)
     # can happen for 'nim check':
     if i >= ff.n.len: return result
@@ -671,8 +671,9 @@ 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:
-      # arrays will deep copy here (pretty bad).
-      var temp = newTemp(c, arg.typ, formal.info)
+      let typ = newType(tySequence, formal.owner)
+      addSonSkipIntLit(typ, formal.typ[0])
+      var temp = newTemp(c, typ, formal.info)
       addVar(v, temp)
       stmtList.add(newAsgnStmt(c, nkFastAsgn, temp, arg))
       idNodeTablePut(newC.mapping, formal, temp)