From c51741cc353f28071b9fe222f75dcf928511d6ca Mon Sep 17 00:00:00 2001 From: microproofs Date: Fri, 8 Mar 2024 22:58:03 -0500 Subject: [PATCH] fix: mutually recursive zero arg function calls were reaching an unreachable --- crates/aiken-lang/src/gen_uplc.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/aiken-lang/src/gen_uplc.rs b/crates/aiken-lang/src/gen_uplc.rs index 791ca8fa..d0877405 100644 --- a/crates/aiken-lang/src/gen_uplc.rs +++ b/crates/aiken-lang/src/gen_uplc.rs @@ -4153,11 +4153,10 @@ impl<'a> CodeGenerator<'a> { } else { let term = arg_stack.pop().unwrap(); - let zero_arg_functions = self.zero_arg_functions.clone(); - // How we handle zero arg anon functions has changed // We now delay zero arg anon functions and force them on a call operation if let Term::Var(name) = &term { + let zero_arg_functions = self.zero_arg_functions.clone(); let text = &name.text; if let Some((_, air_vec)) = zero_arg_functions.iter().find( @@ -4200,8 +4199,14 @@ impl<'a> CodeGenerator<'a> { } else { Some(term.force()) } + } else if let Term::Apply { .. } = &term { + // Case for mutually recursive zero arg functions + Some(term) } else { - unreachable!("Shouldn't call anything other than var") + unreachable!( + "Shouldn't call anything other than var or apply {:#?}", + term + ) } } }