summary refs log tree commit diff stats
path: root/tests/arc/t19401.nim
blob: 56702a4a2770c21f569d9eed14e671bf2986f1e4 (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
25
26
27
28
29
30
31
32
discard """
  output: '''
delete foo
delete foo
delete foo
'''
  matrix: "--mm:arc"
"""

type Foo = ref object
  data: int
proc delete(self: Foo) 
proc newFoo: Foo =
  let x = 12
  discard x
  new(result, delete)
  result.data = x
proc delete(self: Foo) =
  doAssert self.data == 12
  echo("delete foo")

if isMainModule:
  proc test() =
    let x1 = newFoo()
    let x2 = newFoo()
    discard x1
    discard x2
    var x3: Foo
    new(x3, delete)
    x3.data = 12
    discard x3
  test()