From eabb9b79b2decedbe867a6a515feb77c9e3d02a1 Mon Sep 17 00:00:00 2001 From: flywind Date: Tue, 2 Mar 2021 17:24:45 +0800 Subject: [PATCH] close #5342 add testcase (#17230) * remove unnecessary when statement * remove outdated codes * close #5342 add testcase * update the example --- tests/destructor/t5342.nim | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/destructor/t5342.nim diff --git a/tests/destructor/t5342.nim b/tests/destructor/t5342.nim new file mode 100644 index 0000000000..19354ea64d --- /dev/null +++ b/tests/destructor/t5342.nim @@ -0,0 +1,23 @@ +discard """ + matrix: "--gc:refc; --gc:arc" + output: ''' +1 +2 +here +2 +1 +''' +""" + + +type + A = object + id: int + B = object + a: A +proc `=destroy`(a: var A) = echo a.id +var x = A(id: 1) +var y = B(a: A(id: 2)) +`=destroy`(x) +`=destroy`(y) +echo "here" \ No newline at end of file