diff options
author | Clay Sweetser <clay.sweetser@gmail.com> | 2014-07-08 16:25:13 -0400 |
---|---|---|
committer | Clay Sweetser <clay.sweetser@gmail.com> | 2014-07-08 16:25:13 -0400 |
commit | 27fdc5fe33cff3ba0ad33d055a07d060b0682250 (patch) | |
tree | 598f00be4e69ac8e9000ca9063dc6232d7e04499 | |
parent | 887a1ebe688a01259263ad6e11c9061cfc940456 (diff) | |
download | Nim-27fdc5fe33cff3ba0ad33d055a07d060b0682250.tar.gz |
Fixes #542
-rw-r--r-- | lib/system.nim | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim index 0cd1f77df..88f6be864 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2663,6 +2663,8 @@ when hostOS != "standalone": proc `[]`*[Idx, T](a: array[Idx, T], x: TSlice[int]): seq[T] = ## slice operation for arrays. Negative indexes are **not** supported ## because the array might have negative bounds. + when low(a) < 0: + {.error: "Slicing for arrays with negative indices is unsupported.".} var L = x.b - x.a + 1 newSeq(result, L) for i in 0.. <L: result[i] = a[i + x.a] @@ -2670,6 +2672,8 @@ proc `[]`*[Idx, T](a: array[Idx, T], x: TSlice[int]): seq[T] = proc `[]=`*[Idx, T](a: var array[Idx, T], x: TSlice[int], b: openArray[T]) = ## slice assignment for arrays. Negative indexes are **not** supported ## because the array might have negative bounds. + when low(a) < 0: + {.error: "Slicing for arrays with negative indices is unsupported.".} var L = x.b - x.a + 1 if L == b.len: for i in 0 .. <L: a[i+x.a] = b[i] |