mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 14:23:45 +00:00
25 lines
495 B
Nim
25 lines
495 B
Nim
discard """
|
|
ccodecheck: "'Result[(i_1 - 0)] = eqdup'"
|
|
"""
|
|
|
|
# issue #24626
|
|
|
|
proc arrayWith2[T](y: T, size: static int): array[size, T] {.noinit, nodestroy, raises: [].} =
|
|
## Creates a new array filled with `y`.
|
|
for i in 0..size-1:
|
|
when defined(nimHasDup):
|
|
result[i] = `=dup`(y)
|
|
else:
|
|
wasMoved(result[i])
|
|
`=copy`(result[i], y)
|
|
|
|
proc useArray(x: seq[int]) =
|
|
var a = arrayWith2(x, 2)
|
|
|
|
proc main =
|
|
let x = newSeq[int](100)
|
|
for i in 0..5:
|
|
useArray(x)
|
|
|
|
main()
|