-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #9880 show index and bound in lots of
index out of bounds
errors
- Loading branch information
1 parent
7a66616
commit f3ecc15
Showing
9 changed files
with
64 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
template formatErrorIndexBound*[T](i, a, b: T): string = | ||
"index out of bounds: (a:" & $a & ") <= (i:" & $i & ") <= (b:" & $b & ") " | ||
|
||
template formatErrorIndexBound*[T](i, n: T): string = | ||
"index out of bounds: (i:" & $i & ") <= (n:" & $n & ") " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |