t5342.nim 268 B

123456789101112131415161718192021222324
  1. discard """
  2. matrix: "--mm:refc; --mm:arc"
  3. targets: "c js"
  4. output: '''
  5. 1
  6. 2
  7. here
  8. 2
  9. 1
  10. '''
  11. """
  12. type
  13. A = object
  14. id: int
  15. B = object
  16. a: A
  17. proc `=destroy`(a: var A) = echo a.id
  18. var x = A(id: 1)
  19. var y = B(a: A(id: 2))
  20. `=destroy`(x)
  21. `=destroy`(y)
  22. echo "here"