forked from AbleScript/ablescript
Fixed zero division and zero assertion errors when [] / 0
This commit is contained in:
parent
43b00e607a
commit
22e8f63bac
|
@ -760,8 +760,15 @@ impl ops::Div for Value {
|
|||
}
|
||||
}),
|
||||
Value::Cart(c) => {
|
||||
let cart_len = c.len();
|
||||
let chunk_len = rhs.into_isize() as usize;
|
||||
let cart_len = match c.len() {
|
||||
0 => return Value::Cart(HashMap::new()),
|
||||
l => l,
|
||||
};
|
||||
|
||||
let chunk_len = match rhs.into_isize() as usize {
|
||||
0 => rand::thread_rng().gen_range(1..=cart_len),
|
||||
l => l,
|
||||
};
|
||||
|
||||
Value::Cart(
|
||||
c.into_iter()
|
||||
|
|
Loading…
Reference in a new issue