summary refs log tree commit diff stats
path: root/tests/destructor
diff options
context:
space:
mode:
authorflywind <xzsflywind@gmail.com>2021-03-10 14:16:34 +0800
committerGitHub <noreply@github.com>2021-03-09 22:16:34 -0800
commit1655103d83433aa3d4c607c7477281d137d7c794 (patch)
tree79f130c0cb38e75cc54f4f4a5b0b7d53b0964f70 /tests/destructor
parent2f213db7eed7fb715b803559b38af4148cff02e1 (diff)
downloadNim-1655103d83433aa3d4c607c7477281d137d7c794.tar.gz
close #16607 add testcase (#17317)
Diffstat (limited to 'tests/destructor')
-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()