Skip to content

Commit

Permalink
fix: if the value of the right bound in a slice operator was greater …
Browse files Browse the repository at this point in the history
…than the underlying container, a panic occurred
  • Loading branch information
godzie44 committed May 18, 2024
1 parent 7fcd122 commit 80d8cda
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/debugger/variable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ impl ArrayVariable {
}

if let Some(right) = right {
items.drain(right - left.unwrap_or_default()..);
let remove_range = right - left.unwrap_or_default()..;
if remove_range.start < items.len() {
items.drain(remove_range);
};
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/test_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,12 @@ def test_custom_select(self):
'4: i32(3)',
'}',
)
self.debugger.cmd(
'var arr_1[4..6]',
'arr_1 = [i32] {',
'4: i32(3)',
'}',
)
self.debugger.cmd(
'var arr_1[2..4][1..]',
'arr_1 = [i32] {',
Expand Down

0 comments on commit 80d8cda

Please sign in to comment.