parent
92c4aad205
commit
37692baf49
2 changed files with 31 additions and 5 deletions
|
|
@ -560,8 +560,8 @@ proc putArgInto(arg: PNode, formal: PType): TPutArgInto =
|
||||||
of nkBracket:
|
of nkBracket:
|
||||||
return paFastAsgnTakeTypeFromArg
|
return paFastAsgnTakeTypeFromArg
|
||||||
else:
|
else:
|
||||||
return paDirectMapping # XXX really correct?
|
# XXX incorrect, causes #13417 when `arg` has side effects.
|
||||||
# what if ``arg`` has side-effects?
|
return paDirectMapping
|
||||||
case arg.kind
|
case arg.kind
|
||||||
of nkEmpty..nkNilLit:
|
of nkEmpty..nkNilLit:
|
||||||
result = paDirectMapping
|
result = paDirectMapping
|
||||||
|
|
@ -671,9 +671,8 @@ proc transformFor(c: PTransf, n: PNode): PNode =
|
||||||
idNodeTablePut(newC.mapping, formal, arg)
|
idNodeTablePut(newC.mapping, formal, arg)
|
||||||
# XXX BUG still not correct if the arg has a side effect!
|
# XXX BUG still not correct if the arg has a side effect!
|
||||||
of paComplexOpenarray:
|
of paComplexOpenarray:
|
||||||
let typ = newType(tySequence, formal.owner)
|
# arrays will deep copy here (pretty bad).
|
||||||
addSonSkipIntLit(typ, formal.typ[0])
|
var temp = newTemp(c, arg.typ, formal.info)
|
||||||
var temp = newTemp(c, typ, formal.info)
|
|
||||||
addVar(v, temp)
|
addVar(v, temp)
|
||||||
stmtList.add(newAsgnStmt(c, nkFastAsgn, temp, arg))
|
stmtList.add(newAsgnStmt(c, nkFastAsgn, temp, arg))
|
||||||
idNodeTablePut(newC.mapping, formal, temp)
|
idNodeTablePut(newC.mapping, formal, temp)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,15 @@ end
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
7
|
7
|
||||||
|
9002
|
||||||
|
9004
|
||||||
|
9006
|
||||||
|
9008
|
||||||
|
9010
|
||||||
|
9012
|
||||||
|
9014
|
||||||
|
9016
|
||||||
|
9018
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -213,3 +222,21 @@ block t2023_objiter:
|
||||||
|
|
||||||
var o = init()
|
var o = init()
|
||||||
echo(o.iter())
|
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()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue