summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-05-12 02:49:47 +0800
committerGitHub <noreply@github.com>2023-05-11 20:49:47 +0200
commitebbad9e9604d778c32838c981c8748f3675d2659 (patch)
tree72e3bec49ef59c620ce3b59e81e53c03b535234c /tests
parentc00448358121bbf6b5e1fcfe39bb6eb3359d6462 (diff)
downloadNim-ebbad9e9604d778c32838c981c8748f3675d2659.tar.gz
cursor fields cannot form reference cycles (#21832)
* cursor fields cannot form a reference cycle

* fixes typo

* fixes position
Diffstat (limited to 'tests')
-rw-r--r--tests/types/tcyclic.nim20
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/types/tcyclic.nim b/tests/types/tcyclic.nim
index fc2852c49..651394c8b 100644
--- a/tests/types/tcyclic.nim
+++ b/tests/types/tcyclic.nim
@@ -51,10 +51,7 @@ cyclicNo((Cyclone, ))
 cyclicNo(Acyclic)
 
 cyclicYes(LinkedNode)
-
-when false:
-  # todo fix me
-  cyclicNo(LinkedNodeWithCursor)
+cyclicNo(LinkedNodeWithCursor) # cursor doesn't increase rc, cannot form a cycle
 
 type
   ObjectWithoutCycles = object
@@ -121,3 +118,18 @@ block:
   proc `=trace`(x: var myseq[Node]; env: pointer) = discard
 
   cyclicYes(Node)
+
+block:
+  type
+    Foo = object
+      id: ptr ref Foo
+
+  cyclicNo(Foo)
+
+block:
+  type
+    InheritableObj = object of RootObj
+    InheritableRef = ref object of RootObj
+
+  cyclicYes(InheritableObj)
+  cyclicYes(InheritableRef)