Closed
Description
When using openArray type in iterator, if the argument is function call, it will be evaluated many times.
Example
proc p1(): seq[int] =
echo "next"
@[1,2]
iterator ip1(v: openArray[int]): auto =
for x in v:
yield x
for x in ip1(p1()):
echo x
Current Output
next
next
1
next
next
2
next
Expected Output
next
1
2
$ nim -v
Nim Compiler Version 1.1.1 [Windows: i386]
Compiled at 2020-01-27
Copyright (c) 2006-2019 by Andreas Rumpf
active boot switches: -d:release