diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2018-12-06 15:42:44 -0800 |
---|---|---|
committer | Timothee Cour <timothee.cour2@gmail.com> | 2018-12-09 16:50:45 -0800 |
commit | f3ecc15a94c12b149f0665d250af1d71dd128721 (patch) | |
tree | 5ddd43e4b49bbd6ef72625fdbcd0c5864dc74748 /lib/pure/collections | |
parent | 7a66616d741106d4c18ce2e8f843a8b5d31f6025 (diff) | |
download | Nim-f3ecc15a94c12b149f0665d250af1d71dd128721.tar.gz |
refs #9880 show index and bound in lots of `index out of bounds` errors
Diffstat (limited to 'lib/pure/collections')
-rw-r--r-- | lib/pure/collections/sharedstrings.nim | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/pure/collections/sharedstrings.nim b/lib/pure/collections/sharedstrings.nim index 7e9de4b73..b283cd4b1 100644 --- a/lib/pure/collections/sharedstrings.nim +++ b/lib/pure/collections/sharedstrings.nim @@ -12,6 +12,8 @@ type UncheckedCharArray = UncheckedArray[char] +import system/helpers2 + type Buffer = ptr object refcount: int @@ -49,11 +51,11 @@ proc len*(s: SharedString): int = s.len proc `[]`*(s: SharedString; i: Natural): char = if i < s.len: result = s.buffer.data[i+s.first] - else: raise newException(IndexError, "index out of bounds") + else: raise newException(IndexError, formatErrorIndexBound(i, s.len-1)) proc `[]=`*(s: var SharedString; i: Natural; value: char) = if i < s.len: s.buffer.data[i+s.first] = value - else: raise newException(IndexError, "index out of bounds") + else: raise newException(IndexError, formatErrorIndexBound(i, s.len-1)) proc `[]`*(s: SharedString; ab: HSlice[int, int]): SharedString = #incRef(src.buffer) |