fix: mutually recursive zero arg function calls were reaching an unreachable

This commit is contained in:
microproofs 2024-03-08 22:58:03 -05:00
parent 77faee672e
commit c51741cc35
1 changed files with 8 additions and 3 deletions

View File

@ -4153,11 +4153,10 @@ impl<'a> CodeGenerator<'a> {
} else { } else {
let term = arg_stack.pop().unwrap(); let term = arg_stack.pop().unwrap();
let zero_arg_functions = self.zero_arg_functions.clone();
// How we handle zero arg anon functions has changed // How we handle zero arg anon functions has changed
// We now delay zero arg anon functions and force them on a call operation // We now delay zero arg anon functions and force them on a call operation
if let Term::Var(name) = &term { if let Term::Var(name) = &term {
let zero_arg_functions = self.zero_arg_functions.clone();
let text = &name.text; let text = &name.text;
if let Some((_, air_vec)) = zero_arg_functions.iter().find( if let Some((_, air_vec)) = zero_arg_functions.iter().find(
@ -4200,8 +4199,14 @@ impl<'a> CodeGenerator<'a> {
} else { } else {
Some(term.force()) Some(term.force())
} }
} else if let Term::Apply { .. } = &term {
// Case for mutually recursive zero arg functions
Some(term)
} else { } else {
unreachable!("Shouldn't call anything other than var") unreachable!(
"Shouldn't call anything other than var or apply {:#?}",
term
)
} }
} }
} }