t19401.nim 489 B

123456789101112131415161718192021222324252627282930313233
  1. discard """
  2. output: '''
  3. delete foo
  4. delete foo
  5. delete foo
  6. '''
  7. matrix: "--mm:arc"
  8. """
  9. type Foo = ref object
  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()