t19402.nim 498 B

1234567891011121314151617181920212223242526272829303132
  1. discard """
  2. output: '''
  3. delete foo
  4. delete foo
  5. delete foo
  6. '''
  7. matrix: "--mm:arc"
  8. """
  9. type Foo = ref object of RootObj
  10. data: int
  11. proc delete(self: Foo)
  12. proc newFoo: Foo =
  13. let x = 12
  14. discard x
  15. new(result, delete)
  16. result.data = x
  17. proc delete(self: Foo) =
  18. doAssert self.data == 12
  19. echo("delete foo")
  20. if isMainModule:
  21. proc test() =
  22. let x1 = newFoo()
  23. let x2 = newFoo()
  24. discard x1
  25. discard x2
  26. var x3: Foo
  27. new(x3, delete)
  28. x3.data = 12
  29. discard x3
  30. test()