We're testing some properties of subroutines in FunctionState like so:
assert!(
state.function_state.subroutines.iter().all(|subroutine| {
if let Label(subroutine_label) = subroutine.first().unwrap() {
assert!(all_subroutines.insert(subroutine_label.to_owned()), "subroutine labels must be unique");
} else {
panic!("Each subroutine must begin with a label");
}
let ends_with_return_or_recurse = *subroutine.last().unwrap() == return_()
|| *subroutine.last().unwrap() == recurse();
let contains_return = subroutine.iter().any(|x| *x == return_());
ends_with_return_or_recurse && contains_return
}),
"Each subroutine must begin with a label, contain a return and end with a return or a recurse"
);
Instead of doing this test inline, we should add a struct for Subroutine which can either be verified, or is verified in its constructor. So the field subroutines in FunctionsState should have its type changed to Vec<Subroutine>.
We're testing some properties of subroutines in
FunctionState
like so:Instead of doing this test inline, we should add a struct for
Subroutine
which can either be verified, or is verified in its constructor. So the fieldsubroutines
inFunctionsState
should have its type changed toVec<Subroutine>
.