* Make index out of bounds more useful by including the 'bounds'. * fixes #9880 index out of bounds (remaining cases); revives #10228 * change err msg to: `index 3 not in 0 .. 1`
This commit is contained in:
parent
8f05b34125
commit
942495611b
11 changed files with 88 additions and 36 deletions
|
|
@ -47,7 +47,7 @@
|
|||
include "system/inclrtl"
|
||||
|
||||
import
|
||||
strutils, pathnorm
|
||||
strutils, pathnorm, system/indexerrors
|
||||
|
||||
const weirdTarget = defined(nimscript) or defined(js)
|
||||
|
||||
|
|
@ -2551,7 +2551,7 @@ elif defined(windows):
|
|||
ownArgv = parseCmdLine($getCommandLine())
|
||||
ownParsedArgv = true
|
||||
if i < ownArgv.len and i >= 0: return TaintedString(ownArgv[i])
|
||||
raise newException(IndexError, "invalid index")
|
||||
raise newException(IndexError, formatErrorIndexBound(i, ownArgv.len-1))
|
||||
|
||||
elif defined(genode):
|
||||
proc paramStr*(i: int): TaintedString =
|
||||
|
|
@ -2570,7 +2570,7 @@ elif not defined(createNimRtl) and
|
|||
proc paramStr*(i: int): TaintedString {.tags: [ReadIOEffect].} =
|
||||
# Docstring in nimdoc block.
|
||||
if i < cmdCount and i >= 0: return TaintedString($cmdLine[i])
|
||||
raise newException(IndexError, "invalid index")
|
||||
raise newException(IndexError, formatErrorIndexBound(i, cmdCount-1))
|
||||
|
||||
proc paramCount*(): int {.tags: [ReadIOEffect].} =
|
||||
# Docstring in nimdoc block.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue