summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-01-10 23:37:05 +0100
committerAraq <rumpf_a@web.de>2015-01-10 23:52:29 +0100
commit27141f601631410d18135a1e1db974177bf142e1 (patch)
tree71a5a51f30c44d1b073021ae2b340237072bb9f4 /tests
parent8cb31d86b66457e9db848bb3f55f25fe58c4a7da (diff)
downloadNim-27141f601631410d18135a1e1db974177bf142e1.tar.gz
fixes #1803
Diffstat (limited to 'tests')
-rw-r--r--tests/iter/tshallowcopy_closures.nim31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/iter/tshallowcopy_closures.nim b/tests/iter/tshallowcopy_closures.nim
new file mode 100644
index 000000000..2f024ee7e
--- /dev/null
+++ b/tests/iter/tshallowcopy_closures.nim
@@ -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()