diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2022-12-06 05:27:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-05 22:27:18 +0100 |
commit | b83bd282dcd6ba8e26fc838ba968089f86b614b4 (patch) | |
tree | 8ec3fd995c6f9bafe0be287f858d87f31c73bd80 /tests/arc | |
parent | a8090f7d650a5d7ef51416c9fe2708be0de50e95 (diff) | |
download | Nim-b83bd282dcd6ba8e26fc838ba968089f86b614b4.tar.gz |
fixes #20954; bounchecks for len(toOpenArray()) [backport] (#20956)
* bounchecks for len(toOpenArray()) * add a testcase
Diffstat (limited to 'tests/arc')
-rw-r--r-- | tests/arc/topenarray.nim | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/arc/topenarray.nim b/tests/arc/topenarray.nim index 03ec7adf2..47c26a11f 100644 --- a/tests/arc/topenarray.nim +++ b/tests/arc/topenarray.nim @@ -22,3 +22,19 @@ block: # bug 18627 for i in params.toOpenArray(0, params.len - 1): echo i uciLoop2() + +when defined(nimPreviewSlimSystem): + import std/assertions + +block: # bug #20954 + block: + doAssertRaises(IndexDefect): + var v: array[10, int] + + echo len(toOpenArray(v, 20, 30)) + + block: + doAssertRaises(IndexDefect): + var v: seq[int] + + echo len(toOpenArray(v, 20, 30)) |