fixes #1803
This commit is contained in:
parent
8cb31d86b6
commit
27141f6016
2 changed files with 53 additions and 6 deletions
31
tests/iter/tshallowcopy_closures.nim
Normal file
31
tests/iter/tshallowcopy_closures.nim
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
discard """
|
||||
ccodecheck: "!@('{' \\s* 'NI HEX3Astate;' \\s* '}')"
|
||||
"""
|
||||
|
||||
# bug #1803
|
||||
type TaskFn = iterator (): float
|
||||
|
||||
iterator a1(): float {.closure.} =
|
||||
var k = 10
|
||||
while k > 0:
|
||||
echo "a1 ", k
|
||||
dec k
|
||||
yield 1.0
|
||||
|
||||
|
||||
iterator a2(): float {.closure.} =
|
||||
var k = 15
|
||||
while k > 0:
|
||||
echo "a2 ", k
|
||||
dec k
|
||||
yield 2.0
|
||||
|
||||
var
|
||||
x = a1
|
||||
y = a2
|
||||
z: TaskFn
|
||||
|
||||
discard x()
|
||||
z = x #shallowCopy(z, x)
|
||||
z = y #shallowCopy(z, y)
|
||||
discard x()
|
||||
Loading…
Add table
Add a link
Reference in a new issue