tswap.nim 365 B

12345678910111213141516171819202122232425
  1. discard """
  2. nimout: '''
  3. x.data = @[10]
  4. y = @[11]
  5. x.data = @[11]
  6. y = @[10]'''
  7. """
  8. # bug #2946
  9. proc testSwap(): int {.compiletime.} =
  10. type T = object
  11. data: seq[int]
  12. var x: T
  13. x.data = @[10]
  14. var y = @[11]
  15. echo "x.data = ", x.data
  16. echo "y = ", y
  17. swap(y, x.data)
  18. echo "x.data = ", x.data
  19. echo "y = ", y
  20. result = 99
  21. const something = testSwap()