Better range error messages (#19867)

* Better range error messages

* Revert to old behavior for arrays

* Small corrections
This commit is contained in:
Tanguy 2022-06-15 16:38:12 +02:00 • committed by GitHub
commit d33e112766
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -16,6 +16,9 @@ proc raiseRangeError(val: BiggestInt) {.compilerproc, noinline.} =
else:
sysFatal(RangeDefect, "value out of range: ", $val)
proc raiseIndexError4(l1, h1, h2: int) {.compilerproc, noinline.} =
sysFatal(IndexDefect, "index out of bounds: " & $l1 & ".." & $h1 & " notin 0.." & $(h2 - 1))
proc raiseIndexError3(i, a, b: int) {.compilerproc, noinline.} =
sysFatal(IndexDefect, formatErrorIndexBound(i, a, b))