summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorcooldome <cdome@bk.ru>2019-12-24 19:34:14 +0000
committerAndreas Rumpf <rumpf_a@web.de>2019-12-24 20:34:14 +0100
commit649bf326bfc6b4eb983403d850b1dcfc0cc854ae (patch)
tree0400f65b3e8d51573a967f298f72b81bfa5ac782
parent30162908b098d98954cd6de0da91b96f79aad3ba (diff)
downloadNim-649bf326bfc6b4eb983403d850b1dcfc0cc854ae.tar.gz
fixes #12945 (#12959)
-rw-r--r--compiler/semexprs.nim12
-rw-r--r--tests/iter/tmoditer.nim4
2 files changed, 8 insertions, 8 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index ce0f10298..3662b397c 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -1789,12 +1789,12 @@ proc semYieldVarResult(c: PContext, n: PNode, restype: PType) =
       let e = skipTypes(t[i], {tyGenericInst, tyAlias, tySink})
       if e.kind in {tyVar, tyLent}:
         e.flags.incl tfVarIsPtr # bugfix for #4048, #4910, #6892
-        if n[0].kind in {nkPar, nkTupleConstr}:
-          n[0][i] = takeImplicitAddr(c, n[0][i], e.kind == tyLent)
-        elif n[0].kind in {nkHiddenStdConv, nkHiddenSubConv} and
-             n[0][1].kind in {nkPar, nkTupleConstr}:
-          var a = n[0][1]
-          a[i] = takeImplicitAddr(c, a[i], e.kind == tyLent)
+        let tupleConstr = if n[0].kind in {nkHiddenStdConv, nkHiddenSubConv}: n[0][1] else: n[0]
+        if tupleConstr.kind in {nkPar, nkTupleConstr}:
+          if tupleConstr[i].kind == nkExprColonExpr:
+            tupleConstr[i][1] = takeImplicitAddr(c, tupleConstr[i][1], e.kind == tyLent)
+          else:
+            tupleConstr[i] = takeImplicitAddr(c, tupleConstr[i], e.kind == tyLent)
         else:
           localError(c.config, n[0].info, errXExpected, "tuple constructor")
   else: discard
diff --git a/tests/iter/tmoditer.nim b/tests/iter/tmoditer.nim
index 34c6321ce..b92a416fb 100644
--- a/tests/iter/tmoditer.nim
+++ b/tests/iter/tmoditer.nim
@@ -4,7 +4,7 @@ discard """
 
 iterator modPairs(a: var array[0..4,string]): tuple[key: int, val: var string] =
   for i in 0..a.high:
-    yield (i, a[i])
+    yield (key: i, val: a[i])
 
 iterator modItems*[T](a: var array[0..4,T]): var T =
   for i in 0..a.high:
@@ -49,7 +49,7 @@ iterator lentItems[T](a: openarray[T]): lent T =
 
 iterator lentPairs[T](a: array[0..1, T]): tuple[key: int, val: lent T] =
   for i in 0..a.high:
-    yield (i, a[i])
+    yield (key: i, val: a[i])
 
 
 let arr1 = [1, 2, 3]