summary refs log tree commit diff stats
path: root/lib/system/indices.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system/indices.nim')
-rw-r--r--lib/system/indices.nim5
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.