Skip to content

Commit

Permalink
Use HintError instead of assert
Browse files Browse the repository at this point in the history
  • Loading branch information
notlesh committed Sep 26, 2024
1 parent cc51c8b commit ce02a53
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions vm/src/hint_processor/cairo_1_hint_processor/dict_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,14 @@ impl DictManagerExecScope {
// there is nothing to do unless there are at least two segments.
if self.use_temporary_segments && self.trackers.len() > 1 {
let first_segment = self.trackers.get(0).unwrap();
assert!(first_segment.start.segment_index >= 0, "First dict segment should not be temporary");
if first_segment.start.segment_index < 0 {
return Err(HintError::CustomHint("First dict segment should not be temporary".to_string().into_boxed_str()));
}
let mut prev_end = first_segment.end.unwrap_or_default();
for tracker in &self.trackers[1..] {
assert!(tracker.start.segment_index < 0, "Dict segment should be temporary");
if tracker.start.segment_index >= 0 {
return Err(HintError::CustomHint("Dict segment should be temporary".to_string().into_boxed_str()));
}
vm.add_relocation_rule(tracker.start, prev_end)?;
prev_end += (tracker.end.unwrap_or_default() - tracker.start)?;
prev_end += 1;
Expand Down

0 comments on commit ce02a53

Please sign in to comment.