summary refs log tree commit diff stats
path: root/tests/destructor
diff options
context:
space:
mode:
authorcooldome <cdome@bk.ru>2020-03-17 15:36:38 +0000
committerGitHub <noreply@github.com>2020-03-17 16:36:38 +0100
commit35d14095edcb530535a3f2b7e7e759c0f993e2c9 (patch)
tree506d43aedc15417800f13f519eaa0373a4d46287 /tests/destructor
parentaf9c85270198455c7ba218fae919e79060a8960a (diff)
downloadNim-35d14095edcb530535a3f2b7e7e759c0f993e2c9.tar.gz
Fixes #13659 (#13674)
* fixes #13659

Co-authored-by: cooldome <ariabushenko@bk.ru>
Diffstat (limited to 'tests/destructor')
-rw-r--r--tests/destructor/tselect.nim26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/destructor/tselect.nim b/tests/destructor/tselect.nim
index 9262b47d4..c22bf7203 100644
--- a/tests/destructor/tselect.nim
+++ b/tests/destructor/tselect.nim
@@ -1,6 +1,9 @@
 discard """
    output: '''abcsuffix
-xyzsuffix'''
+xyzsuffix
+destroy foo 2
+destroy foo 1
+'''
   cmd: '''nim c --gc:arc $file'''
 """
 
@@ -24,3 +27,24 @@ proc test(param: string; cond: bool) =
 
 test("suffix", true)
 test("suffix", false)
+
+
+
+#--------------------------------------------------------------------
+# issue #13659
+
+type
+  Foo = ref object
+    data: int
+    parent: Foo
+
+proc `=destroy`(self: var type(Foo()[])) =
+  echo "destroy foo ", self.data
+  for i in self.fields: i.reset
+
+proc getParent(self: Foo): Foo = self.parent
+
+var foo1 = Foo(data: 1)
+var foo2 = Foo(data: 2, parent: foo1)
+
+foo2.getParent.data = 1
\ No newline at end of file