summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorcooldome <cdome@bk.ru>2020-03-31 20:15:06 +0100
committerGitHub <noreply@github.com>2020-03-31 21:15:06 +0200
commitc70b3952ff6fc181875c3ca1a28c6bba6617c1a8 (patch)
tree0a521ee88dfe1b637a7f4c456ea7d5f510f8d822
parent9134bb9cfb81297d00ccd6d41fe975e853fca2e5 (diff)
downloadNim-c70b3952ff6fc181875c3ca1a28c6bba6617c1a8.tar.gz
fixes #13810 (#13821)
Co-authored-by: cooldome <ariabushenko@bk.ru>
-rw-r--r--compiler/liftdestructors.nim2
-rw-r--r--tests/arc/tarcmisc.nim23
2 files changed, 23 insertions, 2 deletions
diff --git a/compiler/liftdestructors.nim b/compiler/liftdestructors.nim
index 9a91ec2e9..9e19b9bc2 100644
--- a/compiler/liftdestructors.nim
+++ b/compiler/liftdestructors.nim
@@ -128,7 +128,7 @@ proc fillBodyObj(c: var TLiftCtx; n, body, x, y: PNode; enforceDefaultOp: bool)
 
 proc fillBodyObjTImpl(c: var TLiftCtx; t: PType, body, x, y: PNode) =
   if t.len > 0 and t[0] != nil:
-    fillBodyObjTImpl(c, skipTypes(t[0], abstractPtrs), body, x, y)
+    fillBody(c, skipTypes(t[0], abstractPtrs), body, x, y)
   fillBodyObj(c, t.n, body, x, y, enforceDefaultOp = false)
 
 proc fillBodyObjT(c: var TLiftCtx; t: PType, body, x, y: PNode) =
diff --git a/tests/arc/tarcmisc.nim b/tests/arc/tarcmisc.nim
index 9662ecf7f..687254794 100644
--- a/tests/arc/tarcmisc.nim
+++ b/tests/arc/tarcmisc.nim
@@ -2,7 +2,9 @@ discard """
   output: '''
 destroyed: false
 destroyed: false
-destroying variable'''
+closed
+destroying variable
+'''
   cmd: "nim c --gc:arc $file"
 """
 
@@ -27,3 +29,22 @@ proc test(count: int) =
   echo "destroyed: ", v.isNil
 
 test(3)
+
+
+#------------------------------------------------------------------------------
+# issue #13810
+
+import streams
+
+type
+  A = ref AObj
+  AObj = object of RootObj
+    io: Stream
+  B = ref object of A
+    x: int
+
+proc `=destroy`(x: var AObj) =
+  close(x.io)
+  echo "closed"
+  
+var x = B(io: newStringStream("thestream"))