fixes #1833
This commit is contained in:
parent
bb3dae3a91
commit
71d3cccb07
2 changed files with 22 additions and 1 deletions
|
|
@ -1569,7 +1569,8 @@ proc genRangeChck(p: BProc, n: PNode, d: var TLoc, magic: string) =
|
||||||
toRope(magic)]))
|
toRope(magic)]))
|
||||||
|
|
||||||
proc genConv(p: BProc, e: PNode, d: var TLoc) =
|
proc genConv(p: BProc, e: PNode, d: var TLoc) =
|
||||||
if compareTypes(e.typ, e.sons[1].typ, dcEqIgnoreDistinct):
|
let destType = e.typ.skipTypes({tyVar, tyGenericInst})
|
||||||
|
if compareTypes(destType, e.sons[1].typ, dcEqIgnoreDistinct):
|
||||||
expr(p, e.sons[1], d)
|
expr(p, e.sons[1], d)
|
||||||
else:
|
else:
|
||||||
genSomeCast(p, e, d)
|
genSomeCast(p, e, d)
|
||||||
|
|
|
||||||
20
tests/ccgbugs/twrong_tupleconv.nim
Normal file
20
tests/ccgbugs/twrong_tupleconv.nim
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
# bug #1833
|
||||||
|
iterator myitems*[T](a: var seq[T]): var T {.inline.} =
|
||||||
|
## iterates over each item of `a` so that you can modify the yielded value.
|
||||||
|
var i = 0
|
||||||
|
let L = len(a)
|
||||||
|
while i < L:
|
||||||
|
yield a[i]
|
||||||
|
inc(i)
|
||||||
|
assert(len(a) == L, "seq modified while iterating over it")
|
||||||
|
|
||||||
|
# Works fine
|
||||||
|
var xs = @[1,2,3]
|
||||||
|
for x in myitems(xs):
|
||||||
|
inc x
|
||||||
|
|
||||||
|
# Tuples don't work
|
||||||
|
var ys = @[(1,"a"),(2,"b"),(3,"c")]
|
||||||
|
for y in myitems(ys):
|
||||||
|
inc y[0]
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue