mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
array.slice(): bounds out of range check
This commit is contained in:
@@ -136,8 +136,11 @@ pub fn (s array) slice(start, _end int) array {
|
|||||||
if start > end {
|
if start > end {
|
||||||
panic('invalid slice index: $start > $end')
|
panic('invalid slice index: $start > $end')
|
||||||
}
|
}
|
||||||
if end >= s.len {
|
if end > s.len {
|
||||||
end = s.len
|
panic('runtime error: slice bounds out of range ($end >= $s.len)')
|
||||||
|
}
|
||||||
|
if start < 0 {
|
||||||
|
panic('runtime error: slice bounds out of range ($start < 0)')
|
||||||
}
|
}
|
||||||
l := end - start
|
l := end - start
|
||||||
res := array {
|
res := array {
|
||||||
|
|||||||
Reference in New Issue
Block a user