fix: remove unwrap which is causing panics closes #1073

This commit is contained in:
rvcas
2024-12-25 23:14:11 -05:00
parent 1f1ca4f807
commit 3e2ca757cd
4 changed files with 24 additions and 15 deletions

View File

@@ -461,7 +461,12 @@ impl Converter {
fn get_unique(&mut self, index: &DeBruijn) -> Result<Unique, Error> {
for scope in self.levels.iter().rev() {
let index = Level(self.current_level.0 - index.inner());
let index = Level(
self.current_level
.0
.checked_sub(index.inner())
.ok_or(Error::FreeIndex(*index))?,
);
if let Some(unique) = scope.get_right(&index) {
return Ok(*unique);