array.slice(): bounds out of range check
parent
ac238a5362
commit
4d5336897e
|
@ -136,8 +136,11 @@ pub fn (s array) slice(start, _end int) array {
|
|||
if start > end {
|
||||
panic('invalid slice index: $start > $end')
|
||||
}
|
||||
if end >= s.len {
|
||||
end = s.len
|
||||
if 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
|
||||
res := array {
|
||||
|
|
Loading…
Reference in New Issue