tnodestroyexplicithook.nim 493 B

12345678910111213141516171819202122232425
  1. discard """
  2. ccodecheck: "'Result[(i - 0)] = eqdup'"
  3. """
  4. # issue #24626
  5. proc arrayWith2[T](y: T, size: static int): array[size, T] {.noinit, nodestroy, raises: [].} =
  6. ## Creates a new array filled with `y`.
  7. for i in 0..size-1:
  8. when defined(nimHasDup):
  9. result[i] = `=dup`(y)
  10. else:
  11. wasMoved(result[i])
  12. `=copy`(result[i], y)
  13. proc useArray(x: seq[int]) =
  14. var a = arrayWith2(x, 2)
  15. proc main =
  16. let x = newSeq[int](100)
  17. for i in 0..5:
  18. useArray(x)
  19. main()