summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2014-07-09 09:49:10 +0200
committerAndreas Rumpf <rumpf_a@web.de>2014-07-09 09:49:10 +0200
commitec12922c43d132bbff452b1ea57bdabb5b8695de (patch)
treefc4e765715b28def8f9a33296c231821e789bdbd /lib
parentd80d8aa74d4e7471c262d95aedbe0971a1b2672a (diff)
parent27fdc5fe33cff3ba0ad33d055a07d060b0682250 (diff)
downloadNim-ec12922c43d132bbff452b1ea57bdabb5b8695de.tar.gz
Merge pull request #1336 from Varriount/fix-542
Fixes #542
Diffstat (limited to 'lib')
-rw-r--r--lib/system.nim4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim
index ac259c560..3bb632536 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -2664,6 +2664,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]
@@ -2671,6 +2673,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]