summary refs log tree commit diff stats
path: root/tests/destructor/t16607.nim
blob: 5cc9d4a0888cffab35b61c482d5dc40609e55006 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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()