summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-08-11 20:14:35 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-08-11 20:14:44 +0200
commit88b65ea957b286bf7225c63e38b6d83632ee6cce (patch)
treecab2f7904b55e1ee003c48c0c8726363c8ef5ddd /tests
parentdfe067a74a0b62b74bf9680f1982805132ac9ffa (diff)
downloadNim-88b65ea957b286bf7225c63e38b6d83632ee6cce.tar.gz
fixes #6234
Diffstat (limited to 'tests')
-rw-r--r--tests/ccgbugs/twrongrefcounting.nim22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/ccgbugs/twrongrefcounting.nim b/tests/ccgbugs/twrongrefcounting.nim
new file mode 100644
index 000000000..c0c3e0fc2
--- /dev/null
+++ b/tests/ccgbugs/twrongrefcounting.nim
@@ -0,0 +1,22 @@
+discard """
+  output: '''ok'''
+  cmd: "nim c -r --gc:refc -d:useGcAssert -d:useSysAssert -d:fulldebug -d:smokeCycles $file"
+"""
+# bug #6234
+type
+    Foo = ref object
+        s: seq[Bar]
+    Bar = ref object
+        f: Foo
+
+proc test() =
+    var f = Foo.new()
+    for i in 0 .. 5:
+        f.s = @[]
+        for j in 0 .. 5:
+            var b = Bar.new()
+            b.f = f
+            f.s.add(b)
+
+test()
+echo "ok"