mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-29 18:11:44 +00:00
Merge pull request #9881 from timotheecour/pr_ref_9880
refs #9880 show index and bound in lots of `index out of bounds` errors
This commit is contained in:
@@ -1,14 +1,21 @@
|
||||
discard """
|
||||
errormsg: "index out of bounds"
|
||||
line: 11
|
||||
errormsg: "index out of bounds: (a:0) <= (i:2) <= (b:1) "
|
||||
line: 18
|
||||
"""
|
||||
|
||||
block:
|
||||
try:
|
||||
let a = @[1,2]
|
||||
echo a[3]
|
||||
except Exception as e:
|
||||
doAssert e.msg == "index out of bounds: (i:3) <= (n:1) "
|
||||
|
||||
type TTestArr = array[0..1, int16]
|
||||
var f: TTestArr
|
||||
f[0] = 30
|
||||
f[1] = 40
|
||||
f[2] = 50
|
||||
f[3] = 60
|
||||
block:
|
||||
type TTestArr = array[0..1, int16]
|
||||
var f: TTestArr
|
||||
f[0] = 30
|
||||
f[1] = 40
|
||||
f[2] = 50
|
||||
f[3] = 60
|
||||
|
||||
echo(repr(f))
|
||||
echo(repr(f))
|
||||
|
||||
16
tests/misc/tinvalidarrayaccess2.nim
Normal file
16
tests/misc/tinvalidarrayaccess2.nim
Normal file
@@ -0,0 +1,16 @@
|
||||
discard """
|
||||
errormsg: "index out of bounds: (a:0) <= (i:3) <= (b:1) "
|
||||
line: 9
|
||||
"""
|
||||
|
||||
# Note: merge in tinvalidarrayaccess.nim pending https://github.com/nim-lang/Nim/issues/9906
|
||||
|
||||
let a = [1,2]
|
||||
echo a[3]
|
||||
|
||||
when false:
|
||||
# TOOD: this case is not yet handled, giving: "index out of bounds"
|
||||
proc fun()=
|
||||
let a = @[1,2]
|
||||
echo a[3]
|
||||
static: fun()
|
||||
Reference in New Issue
Block a user