fixes #20954; bounchecks for len(toOpenArray()) [backport] (#20956)

* bounchecks for len(toOpenArray())

* add a testcase
This commit is contained in:
ringabout 2022-12-06 05:27:18 +08:00 • committed by GitHub
commit b83bd282dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View file

@ -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))