diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 10a33423e1..eaf8639b0c 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -1077,10 +1077,10 @@ proc genAsgnAux(p: PProc, x, y: PNode, noCopyNeeded: bool) = # supports proc getF(): var T if x.kind in {nkHiddenDeref, nkDerefExpr} and x[0].kind in nkCallKinds: lineF(p, "nimCopy($1, $2, $3);$n", - [a.res, b.res, genTypeInfo(p, y.typ)]) + [a.res, b.res, genTypeInfo(p, x.typ)]) else: lineF(p, "$1 = nimCopy($1, $2, $3);$n", - [a.res, b.res, genTypeInfo(p, y.typ)]) + [a.res, b.res, genTypeInfo(p, x.typ)]) of etyBaseIndex: if a.typ != etyBaseIndex or b.typ != etyBaseIndex: if y.kind == nkCall: diff --git a/tests/js/t16822.nim b/tests/js/t16822.nim new file mode 100644 index 0000000000..687d60be93 --- /dev/null +++ b/tests/js/t16822.nim @@ -0,0 +1,29 @@ +block: # bug #16822 + var scores: seq[(set[char], int)] = @{{'/'} : 10} + + var x1: set[char] + for item in items(scores): + x1 = item[0] + + doAssert x1 == {'/'} + + var x2: set[char] + for (chars, value) in items(scores): + x2 = chars + + doAssert x2 == {'/'} + +block: # bug #14574 + proc fn(): auto = + let a = @[("foo", (12, 13))] + for (k,v) in a: + return (k,v) + doAssert fn() == ("foo", (12, 13)) + +block: # bug #14574 + iterator fn[T](a:T): lent T = yield a + let a = (10, (11,)) + proc bar(): auto = + for (x,y) in fn(a): + return (x,y) + doAssert bar() == (10, (11,)) \ No newline at end of file diff --git a/tests/stdlib/tjsonutils.nim b/tests/stdlib/tjsonutils.nim index 24bc9a3cd5..beb12d5ae0 100644 --- a/tests/stdlib/tjsonutils.nim +++ b/tests/stdlib/tjsonutils.nim @@ -42,8 +42,7 @@ template fn() = block: testRoundtrip({"z": "Z", "y": "Y"}.toOrderedTable): """{"z":"Z","y":"Y"}""" - when not defined(js): # pending https://github.com/nim-lang/Nim/issues/14574 - testRoundtrip({"z": (f1: 'f'), }.toTable): """{"z":{"f1":102}}""" + testRoundtrip({"z": (f1: 'f'), }.toTable): """{"z":{"f1":102}}""" block: testRoundtrip({"name": "John", "city": "Monaco"}.newStringTable): """{"mode":"modeCaseSensitive","table":{"city":"Monaco","name":"John"}}"""