mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
fixes #24033
This commit is contained in:
@@ -410,9 +410,15 @@ proc transformYield(c: PTransf, n: PNode): PNode =
|
||||
result.add transform(c, v)
|
||||
|
||||
for i in 0..<c.transCon.forStmt.len - 2:
|
||||
let lhs = c.transCon.forStmt[i]
|
||||
let rhs = transform(c, newTupleAccess(c.graph, tmp, i))
|
||||
result.add(asgnTo(lhs, rhs))
|
||||
if c.transCon.forStmt[i].kind == nkVarTuple:
|
||||
for j in 0..<c.transCon.forStmt[i].len-1:
|
||||
let lhs = c.transCon.forStmt[i][j]
|
||||
let rhs = transform(c, newTupleAccess(c.graph, newTupleAccess(c.graph, tmp, i), j))
|
||||
result.add(asgnTo(lhs, rhs))
|
||||
else:
|
||||
let lhs = c.transCon.forStmt[i]
|
||||
let rhs = transform(c, newTupleAccess(c.graph, tmp, i))
|
||||
result.add(asgnTo(lhs, rhs))
|
||||
else:
|
||||
for i in 0..<c.transCon.forStmt.len - 2:
|
||||
let lhs = c.transCon.forStmt[i]
|
||||
|
||||
@@ -392,3 +392,19 @@ iterator tryFinally() {.closure.} =
|
||||
|
||||
var x = tryFinally
|
||||
x()
|
||||
|
||||
block: # bug #24033
|
||||
type Query = ref object
|
||||
|
||||
iterator pairs(query: Query): (int, (string, float32)) =
|
||||
var output: (int, (string, float32)) = (0, ("foo", 3.14))
|
||||
for id in @[0, 1, 2]:
|
||||
output[0] = id
|
||||
yield output
|
||||
|
||||
var collections: seq[(int, string, string)]
|
||||
|
||||
for id, (str, num) in Query():
|
||||
collections.add (id, str, $num)
|
||||
|
||||
doAssert collections[1] == (1, "foo", "3.14")
|
||||
|
||||
Reference in New Issue
Block a user