tmove.nim 571 B

1234567891011121314151617181920212223242526272829303132
  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()
  15. import std/deques
  16. block: # bug #24319
  17. var queue = initDeque[array[32, byte]]()
  18. for i in 0 ..< 5:
  19. let element: array[32, byte] = [
  20. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  21. 0, 0, 0, 0, 0, 1,
  22. ]
  23. queue.addLast(element)
  24. doAssert queue.popLast[^1] == byte(1)