* fixes #13659

Co-authored-by: cooldome <ariabushenko@bk.ru>
This commit is contained in:
cooldome 2020-03-17 15:36:38 +00:00 • committed by GitHub
commit 35d14095ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 3 deletions

View file

@ -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