diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-12-11 21:49:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-11 21:49:08 +0100 |
commit | bb1ce398af37ddd75fcac611ee993c85e956154e (patch) | |
tree | d3677e58b8265f992eec8fe24303148da8f408f8 /tests/misc | |
parent | f18fcf65b3a61b1960c14aa9503eea34fee76492 (diff) | |
parent | f3ecc15a94c12b149f0665d250af1d71dd128721 (diff) | |
download | Nim-bb1ce398af37ddd75fcac611ee993c85e956154e.tar.gz |
Merge pull request #9881 from timotheecour/pr_ref_9880
refs #9880 show index and bound in lots of `index out of bounds` errors
Diffstat (limited to 'tests/misc')
-rw-r--r-- | tests/misc/tinvalidarrayaccess.nim | 25 | ||||
-rw-r--r-- | tests/misc/tinvalidarrayaccess2.nim | 16 |
2 files changed, 32 insertions, 9 deletions
diff --git a/tests/misc/tinvalidarrayaccess.nim b/tests/misc/tinvalidarrayaccess.nim index 03105b41b..57ad38b85 100644 --- a/tests/misc/tinvalidarrayaccess.nim +++ b/tests/misc/tinvalidarrayaccess.nim @@ -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)) diff --git a/tests/misc/tinvalidarrayaccess2.nim b/tests/misc/tinvalidarrayaccess2.nim new file mode 100644 index 000000000..86d349457 --- /dev/null +++ b/tests/misc/tinvalidarrayaccess2.nim @@ -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() |