Skip to content

Commit aa84dbe

Browse files
committed
fixup! Parse select and store calls in annotations
1 parent e9f1ff6 commit aa84dbe

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/annot.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -676,12 +676,14 @@ where
676676
let (term, sort) = formula_or_term
677677
.into_term()
678678
.ok_or_else(|| ParseAttrError::unexpected_formula("before projection"))?;
679-
let sort = fields.iter().fold(sort, |acc, field| match (acc, field) {
680-
(acc, Field::Index(idx)) => acc.tuple_elem(*idx),
681-
(acc, Field::Store(_, _)) => acc,
682-
(chc::Sort::Array(_, elem), Field::Select(_)) => *elem,
683-
_ => panic!("invalid field access"),
684-
});
679+
let sort = fields
680+
.iter()
681+
.try_fold(sort, |acc, field| match (acc, field) {
682+
(acc, Field::Index(idx)) => Ok(acc.tuple_elem(*idx)),
683+
(acc, Field::Store(_, _)) => Ok(acc),
684+
(chc::Sort::Array(_, elem), Field::Select(_)) => Ok(*elem),
685+
(acc, _) => Err(ParseAttrError::unsorted_op("select", acc.clone())),
686+
})?;
685687
let term = fields.into_iter().fold(term, |acc, field| match field {
686688
Field::Index(idx) => acc.tuple_proj(idx),
687689
Field::Store(idx, val) => acc.store(idx, val),

0 commit comments

Comments
 (0)