summary refs log tree commit diff stats
path: root/tests/iter/tshallowcopy_closures.nim
blob: 279e7d950754a7125b9ea3041bacffcaf1830b93 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
discard """
  ccodecheck: "!@('{' \\s* 'NI HEX3Astate;' \\s* '}')"
  output: '''
a1 10
a1 9
'''
"""

# 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()
shallowCopy(z, x)
shallowCopy(z, y)
discard x()