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
|
|
@ -8,6 +8,7 @@
|
|||
#
|
||||
|
||||
# Implementation of some runtime checks.
|
||||
import system/helpers2
|
||||
|
||||
proc raiseRangeError(val: BiggestInt) {.compilerproc, noinline.} =
|
||||
when hostOS == "standalone":
|
||||
|
|
@ -15,6 +16,12 @@ proc raiseRangeError(val: BiggestInt) {.compilerproc, noinline.} =
|
|||
else:
|
||||
sysFatal(RangeError, "value out of range: ", $val)
|
||||
|
||||
proc raiseIndexError3(i, a, b: int) {.compilerproc, noinline.} =
|
||||
sysFatal(IndexError, formatErrorIndexBound(i, a, b))
|
||||
|
||||
proc raiseIndexError2(i, n: int) {.compilerproc, noinline.} =
|
||||
sysFatal(IndexError, formatErrorIndexBound(i, n))
|
||||
|
||||
proc raiseIndexError() {.compilerproc, noinline.} =
|
||||
sysFatal(IndexError, "index out of bounds")
|
||||
|
||||
|
|
@ -25,7 +32,7 @@ proc chckIndx(i, a, b: int): int =
|
|||
if i >= a and i <= b:
|
||||
return i
|
||||
else:
|
||||
raiseIndexError()
|
||||
raiseIndexError3(i, a, b)
|
||||
|
||||
proc chckRange(i, a, b: int): int =
|
||||
if i >= a and i <= b:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue