fixes #22852; real bugfix is tied to bug #22672 (#23013)

This commit is contained in:
Andreas Rumpf
2023-11-30 17:59:16 +01:00
committed by GitHub
parent 7ea5aaaebb
commit ab7faa73ef

View File

@@ -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.