refs #9880 show index and bound in lots of index out of bounds errors
This commit is contained in:
parent
7a66616d74
commit
f3ecc15a94
9 changed files with 64 additions and 23 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
from strutils import parseInt, cmpIgnoreStyle, Digits
|
||||
include "system/inclrtl"
|
||||
|
||||
import system/helpers2
|
||||
|
||||
proc findNormalized(x: string, inArray: openarray[string]): int =
|
||||
var i = 0
|
||||
|
|
@ -85,7 +85,7 @@ proc getFormatArg(p: var FormatParser, a: openArray[string]): int =
|
|||
result = parseInt(a[result])-1
|
||||
else:
|
||||
raiseInvalidFormat("'#', '$', number or identifier expected")
|
||||
if result >=% a.len: raiseInvalidFormat("index out of bounds: " & $result)
|
||||
if result >=% a.len: raiseInvalidFormat(formatErrorIndexBound(result, a.len))
|
||||
p.i = i
|
||||
|
||||
proc scanDollar(p: var FormatParser, a: openarray[string], s: var string) {.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue