diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-08-24 06:25:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-24 06:25:47 +0200 |
commit | ce7f29e8e6628df209ecebb566f9cefc14243aaf (patch) | |
tree | e70a04d3bd577274ea5b0380f76043402b596fdc /lib | |
parent | f2e8c39e851b1d1f55d387d80ae3d9f598a6ef0e (diff) | |
download | Nim-ce7f29e8e6628df209ecebb566f9cefc14243aaf.tar.gz |
fixes #11833 (#12018)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/core/seqs.nim | 2 | ||||
-rw-r--r-- | lib/system.nim | 34 |
2 files changed, 20 insertions, 16 deletions
diff --git a/lib/core/seqs.nim b/lib/core/seqs.nim index 2892e4d8a..01839a4de 100644 --- a/lib/core/seqs.nim +++ b/lib/core/seqs.nim @@ -202,7 +202,7 @@ when false: assert i < x.len x.data[i] = y - proc `@`*[T](elems: openArray[T]): NimSeqV2[T] = + proc `@`*[T](elems: sink openArray[T]): NimSeqV2[T] = result.cap = elems.len result.len = elems.len result.data = cast[type(result.data)](alloc(result.cap * sizeof(T))) diff --git a/lib/system.nim b/lib/system.nim index 7e23b5188..09280d607 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -1794,21 +1794,25 @@ proc cmp*(x, y: string): int {.noSideEffect, procvar.} ## **Note**: The precise result values depend on the used C runtime library and ## can differ between operating systems! -proc `@`* [IDX, T](a: array[IDX, T]): seq[T] {. - magic: "ArrToSeq", noSideEffect.} - ## Turns an array into a sequence. - ## - ## This most often useful for constructing - ## sequences with the array constructor: ``@[1, 2, 3]`` has the type - ## ``seq[int]``, while ``[1, 2, 3]`` has the type ``array[0..2, int]``. - ## - ## .. code-block:: Nim - ## let - ## a = [1, 3, 5] - ## b = "foo" - ## - ## echo @a # => @[1, 3, 5] - ## echo @b # => @['f', 'o', 'o'] +when defined(nimHasDefault): + proc `@`* [IDX, T](a: sink array[IDX, T]): seq[T] {. + magic: "ArrToSeq", noSideEffect.} + ## Turns an array into a sequence. + ## + ## This most often useful for constructing + ## sequences with the array constructor: ``@[1, 2, 3]`` has the type + ## ``seq[int]``, while ``[1, 2, 3]`` has the type ``array[0..2, int]``. + ## + ## .. code-block:: Nim + ## let + ## a = [1, 3, 5] + ## b = "foo" + ## + ## echo @a # => @[1, 3, 5] + ## echo @b # => @['f', 'o', 'o'] +else: + proc `@`* [IDX, T](a: array[IDX, T]): seq[T] {. + magic: "ArrToSeq", noSideEffect.} when defined(nimHasDefault): proc default*(T: typedesc): T {.magic: "Default", noSideEffect.} |