summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorMiran <narimiran@disroot.org>2019-06-11 14:34:21 +0200
committerAndreas Rumpf <rumpf_a@web.de>2019-06-11 14:34:21 +0200
commitb3d2cd738a59aa07eea7cb69e944c7db9eed6a86 (patch)
treeab10e6ea75ffffb2b3c2a5f990e0140cde946948 /lib/system
parent639e9a7aa9bed6d2379820e64f3b112241843be2 (diff)
downloadNim-b3d2cd738a59aa07eea7cb69e944c7db9eed6a86.tar.gz
[other] better error message for IndexError for empty containers (#11476)
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/indexerrors.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/system/indexerrors.nim b/lib/system/indexerrors.nim
index 53c52a26a..1b91789bd 100644
--- a/lib/system/indexerrors.nim
+++ b/lib/system/indexerrors.nim
@@ -4,7 +4,8 @@ template formatErrorIndexBound*[T](i, a, b: T): string =
   when defined(standalone):
     "indexOutOfBounds"
   else:
-    "index " & $i & " not in " & $a & " .. " & $b
+    if b < a: "index out of bounds, the container is empty"
+    else: "index " & $i & " not in " & $a & " .. " & $b
 
 template formatErrorIndexBound*[T](i, n: T): string =
   formatErrorIndexBound(i, 0, n)