summary refs log tree commit diff stats
path: root/tests/arc/t19402.nim
blob: 5ee6fc798620e09828c13856874d0f5abb7602fc (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 of RootObj
  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()