diff options
Diffstat (limited to 'tests/destructor')
-rw-r--r-- | tests/destructor/t16607.nim | 24 |
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() |