Skip to content

Commit

Permalink
Merge pull request #64 from AdrienChampion/issue_63
Browse files Browse the repository at this point in the history
fix: prevent stack overflow in array store/select creation
  • Loading branch information
AdrienChampion authored Sep 6, 2023
2 parents d801818 + 247fe26 commit 581e814
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/fun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ where
/// # Examples
///
/// ```rust
/// use hoice::{ common::*, fun, info::VarInfo };
/// use hoice::{ common::*, info::VarInfo };
/// let sig: VarInfos = vec![ VarInfo::new("v_0", typ::int(), 0.into()) ].into();
/// let fun_name = "fun_new_test_identity";
/// let sig = fun::FunSig::new(fun_name, sig, typ::int());
Expand Down
1 change: 0 additions & 1 deletion src/term/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,6 @@ where
///
/// ```rust
/// # use hoice::common::*;
/// use hoice::errors::TypError;
/// let bool_var = term::bool_var(0);
/// let int_term = term::add( vec![ term::int_var(1), term::int(7) ] );
/// let ill_typed = term::try_app( Op::And, vec![ bool_var, int_term ] );
Expand Down
19 changes: 6 additions & 13 deletions src/term/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2161,13 +2161,9 @@ simpl_fun! {
(
Some(array), Some(index), Some(value)
) => {
let result = array.store(index, value).to_term().unwrap_or_else(
|| panic!(
"illegal store application (store {} {} {})",
args[0], args[1], args[0]
)
) ;
Some( NormRes::Term(result) )
let val = array.store(index, value);
let term = term::factory::val(val);
Some(NormRes::Term(term))
},
_ => None,
}
Expand All @@ -2181,12 +2177,9 @@ simpl_fun! {
args[0].val(), args[1].val()
) {
( Some(array), Some(index) ) => {
let result = array.select(index).to_term().unwrap_or_else(
|| panic!(
"illegal select application (select {} {})", args[0], args[1]
)
) ;
Some( NormRes::Term(result) )
let val = array.select(index);
let term = term::factory::val(val);
Some(NormRes::Term(term))
},
_ => None,
}
Expand Down

0 comments on commit 581e814

Please sign in to comment.