diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2023-11-30 17:59:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-30 17:59:16 +0100 |
commit | ab7faa73ef879548be2eaa462eb95c4c8ffd6ef2 (patch) | |
tree | 7abe1eae898d74d0fbe2216e1f93a9ed01fe9f30 | |
parent | 7ea5aaaebb10369f202490581da6912b491503dd (diff) | |
download | Nim-ab7faa73ef879548be2eaa462eb95c4c8ffd6ef2.tar.gz |
fixes #22852; real bugfix is tied to bug #22672 (#23013)
-rw-r--r-- | lib/system/indices.nim | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/system/indices.nim b/lib/system/indices.nim index f4a140346..fb6151a74 100644 --- a/lib/system/indices.nim +++ b/lib/system/indices.nim @@ -112,8 +112,11 @@ proc `[]`*[Idx, T; U, V: Ordinal](a: array[Idx, T], x: HSlice[U, V]): seq[T] {.s ## ``` let xa = a ^^ x.a let L = (a ^^ x.b) - xa + 1 - result = newSeq[T](L) + # Workaround bug #22852: + result = newSeq[T](if L < 0: 0 else: L) for i in 0..<L: result[i] = a[Idx(i + xa)] + # Workaround bug #22852 + discard Natural(L) proc `[]=`*[Idx, T; U, V: Ordinal](a: var array[Idx, T], x: HSlice[U, V], b: openArray[T]) {.systemRaisesDefect.} = ## Slice assignment for arrays. |