summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
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"