summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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()
98 99 100 101 102 103 104 105 106 107 108 109 110