Fix zero position bugs in array methods.
This commit is contained in:
parent
1145c5a4c0
commit
c5e716e71f
@ -6,6 +6,11 @@ Version 0.20.1
|
||||
|
||||
This version enables functions to access constants declared at global level via the special `global` module.
|
||||
|
||||
Bug fixes
|
||||
---------
|
||||
|
||||
* Fixed bug when position is zero in `insert` and `split_at` methods for arrays.
|
||||
|
||||
Breaking changes
|
||||
----------------
|
||||
|
||||
|
@ -35,7 +35,7 @@ mod array_functions {
|
||||
array
|
||||
}
|
||||
pub fn insert(array: &mut Array, position: INT, item: Dynamic) {
|
||||
if position <= 0 {
|
||||
if position < 0 {
|
||||
if let Some(n) = position.checked_abs() {
|
||||
if n as usize > array.len() {
|
||||
array.insert(0, item);
|
||||
@ -174,7 +174,7 @@ mod array_functions {
|
||||
}
|
||||
#[rhai_fn(name = "split")]
|
||||
pub fn split_at(array: &mut Array, start: INT) -> Array {
|
||||
if start <= 0 {
|
||||
if start < 0 {
|
||||
if let Some(n) = start.checked_abs() {
|
||||
if n as usize > array.len() {
|
||||
mem::take(array)
|
||||
|
Loading…
Reference in New Issue
Block a user