* fixes #13659 Co-authored-by: cooldome <ariabushenko@bk.ru>
This commit is contained in:
parent
af9c852701
commit
35d14095ed
2 changed files with 27 additions and 3 deletions
|
|
@ -619,10 +619,10 @@ proc p(n: PNode; c: var Con; mode: ProcessMode): PNode =
|
||||||
if n[0].kind in {nkDotExpr, nkCheckedFieldExpr}:
|
if n[0].kind in {nkDotExpr, nkCheckedFieldExpr}:
|
||||||
cycleCheck(n, c)
|
cycleCheck(n, c)
|
||||||
assert n[1].kind notin {nkAsgn, nkFastAsgn}
|
assert n[1].kind notin {nkAsgn, nkFastAsgn}
|
||||||
result = moveOrCopy(n[0], n[1], c)
|
result = moveOrCopy(p(n[0], c, mode), n[1], c)
|
||||||
else:
|
else:
|
||||||
result = copyNode(n)
|
result = copyNode(n)
|
||||||
result.add copyTree(n[0])
|
result.add p(n[0], c, mode)
|
||||||
result.add p(n[1], c, consumed)
|
result.add p(n[1], c, consumed)
|
||||||
of nkRaiseStmt:
|
of nkRaiseStmt:
|
||||||
if optOwnedRefs in c.graph.config.globalOptions and n[0].kind != nkEmpty:
|
if optOwnedRefs in c.graph.config.globalOptions and n[0].kind != nkEmpty:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''abcsuffix
|
output: '''abcsuffix
|
||||||
xyzsuffix'''
|
xyzsuffix
|
||||||
|
destroy foo 2
|
||||||
|
destroy foo 1
|
||||||
|
'''
|
||||||
cmd: '''nim c --gc:arc $file'''
|
cmd: '''nim c --gc:arc $file'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -24,3 +27,24 @@ proc test(param: string; cond: bool) =
|
||||||
|
|
||||||
test("suffix", true)
|
test("suffix", true)
|
||||||
test("suffix", false)
|
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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue