mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 12:07:51 +00:00
@@ -560,8 +560,8 @@ proc putArgInto(arg: PNode, formal: PType): TPutArgInto =
|
||||
of nkBracket:
|
||||
return paFastAsgnTakeTypeFromArg
|
||||
else:
|
||||
return paDirectMapping # XXX really correct?
|
||||
# what if ``arg`` has side-effects?
|
||||
# XXX incorrect, causes #13417 when `arg` has side effects.
|
||||
return paDirectMapping
|
||||
case arg.kind
|
||||
of nkEmpty..nkNilLit:
|
||||
result = paDirectMapping
|
||||
@@ -671,9 +671,8 @@ 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:
|
||||
let typ = newType(tySequence, formal.owner)
|
||||
addSonSkipIntLit(typ, formal.typ[0])
|
||||
var temp = newTemp(c, typ, formal.info)
|
||||
# arrays will deep copy here (pretty bad).
|
||||
var temp = newTemp(c, arg.typ, formal.info)
|
||||
addVar(v, temp)
|
||||
stmtList.add(newAsgnStmt(c, nkFastAsgn, temp, arg))
|
||||
idNodeTablePut(newC.mapping, formal, temp)
|
||||
|
||||
@@ -18,6 +18,15 @@ end
|
||||
1
|
||||
2
|
||||
7
|
||||
9002
|
||||
9004
|
||||
9006
|
||||
9008
|
||||
9010
|
||||
9012
|
||||
9014
|
||||
9016
|
||||
9018
|
||||
'''
|
||||
"""
|
||||
|
||||
@@ -213,3 +222,21 @@ block t2023_objiter:
|
||||
|
||||
var o = init()
|
||||
echo(o.iter())
|
||||
|
||||
|
||||
block:
|
||||
# issue #13739
|
||||
iterator myIter(arg: openarray[int]): int =
|
||||
var tmp = 0
|
||||
let len = arg.len
|
||||
while tmp < len:
|
||||
yield arg[tmp] * 2
|
||||
inc tmp
|
||||
|
||||
proc someProc() =
|
||||
var data = [4501,4502,4503,4504,4505,4506,4507,4508,4509]
|
||||
# StmtListExpr should not get special treatment.
|
||||
for x in myIter((discard;data)):
|
||||
echo x
|
||||
|
||||
someProc()
|
||||
|
||||
Reference in New Issue
Block a user