From 034dad8e321edcf6cf88a2ad93fceafae267cc74 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 19 Mar 2020 12:57:45 +0100 Subject: fixes #13691 (#13694) --- tests/arc/tarcmisc.nim | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/arc/tarcmisc.nim (limited to 'tests/arc') diff --git a/tests/arc/tarcmisc.nim b/tests/arc/tarcmisc.nim new file mode 100644 index 000000000..9662ecf7f --- /dev/null +++ b/tests/arc/tarcmisc.nim @@ -0,0 +1,29 @@ +discard """ + output: ''' +destroyed: false +destroyed: false +destroying variable''' + cmd: "nim c --gc:arc $file" +""" + +# bug #13691 +type Variable = ref object + value: int + +proc `=destroy`(self: var typeof(Variable()[])) = + echo "destroying variable" + +proc newVariable(value: int): Variable = + result = Variable() + result.value = value + +proc test(count: int) = + var v {.global.} = newVariable(10) + + var count = count - 1 + if count == 0: return + + test(count) + echo "destroyed: ", v.isNil + +test(3) -- cgit 1.4.1-2-gfad0