Skip to content

Commit

Permalink
fixes #13810 (#13821)
Browse files Browse the repository at this point in the history
Co-authored-by: cooldome <ariabushenko@bk.ru>
  • Loading branch information
cooldome and cooldome authored Mar 31, 2020
1 parent 9134bb9 commit c70b395
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compiler/liftdestructors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand Down
23 changes: 22 additions & 1 deletion tests/arc/tarcmisc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ discard """
output: '''
destroyed: false
destroyed: false
destroying variable'''
closed
destroying variable
'''
cmd: "nim c --gc:arc $file"
"""

Expand All @@ -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"))

0 comments on commit c70b395

Please sign in to comment.