tmove.nim 231 B

12345678910111213141516171819
  1. discard """
  2. targets: "c cpp"
  3. """
  4. block:
  5. var called = 0
  6. proc bar(a: var int): var int =
  7. inc called
  8. result = a
  9. proc foo =
  10. var a = 2
  11. var s = move bar(a)
  12. doAssert called == 1
  13. doAssert s == 2
  14. foo()