summary refs log tree commit diff stats
path: root/tests/destructor/t16607.nim
diff options
context:
space:
mode:
authorClyybber <darkmine956@gmail.com>2021-03-12 00:21:31 +0100
committerGitHub <noreply@github.com>2021-03-12 00:21:31 +0100
commit4545995e2de60de63515b2e9f1878ddd8ed1808b (patch)
tree830e6bf674540b59d643826c951db500a91af152 /tests/destructor/t16607.nim
parente922d73dd6b74a0ea9e1588bca945662f0797a9c (diff)
downloadNim-4545995e2de60de63515b2e9f1878ddd8ed1808b.tar.gz
Revert "Revert "close #16607 add testcase (#17317)" (#17336)" (#17347)
This reverts commit 3ce27511adac12785b51ecc33dc9d2a2fcd2f0b8.
Diffstat (limited to 'tests/destructor/t16607.nim')
-rw-r--r--tests/destructor/t16607.nim24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/destructor/t16607.nim b/tests/destructor/t16607.nim
new file mode 100644
index 000000000..5cc9d4a08
--- /dev/null
+++ b/tests/destructor/t16607.nim
@@ -0,0 +1,24 @@
+discard """
+  matrix: "--gc:refc; --gc:arc"
+"""
+
+# bug #16607
+
+type
+  O {.requiresInit.} = object
+    initialized: bool
+
+proc `=destroy`(o: var O) =
+  doAssert o.initialized, "O was destroyed before initialization!"
+
+proc initO(): O =
+  O(initialized: true)
+
+proc pair(): tuple[a, b: O] =
+  result.a = initO()
+  result.b = initO()
+
+proc main() =
+  discard pair()
+
+main()