fix: mutually recursive zero arg functions needed to have their function bodies delayed
This commit is contained in:
parent
7f0df40b4e
commit
bffa678178
|
@ -4201,7 +4201,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
} else if let Term::Apply { .. } = &term {
|
} else if let Term::Apply { .. } = &term {
|
||||||
// Case for mutually recursive zero arg functions
|
// Case for mutually recursive zero arg functions
|
||||||
Some(term)
|
Some(term.force())
|
||||||
} else {
|
} else {
|
||||||
unreachable!(
|
unreachable!(
|
||||||
"Shouldn't call anything other than var or apply {:#?}",
|
"Shouldn't call anything other than var or apply {:#?}",
|
||||||
|
@ -4493,9 +4493,13 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
for (params, func_body) in cyclic_functions.into_iter() {
|
for (params, func_body) in cyclic_functions.into_iter() {
|
||||||
let mut function = func_body;
|
let mut function = func_body;
|
||||||
|
if params.is_empty() {
|
||||||
|
function = function.delay();
|
||||||
|
} else {
|
||||||
for param in params.iter().rev() {
|
for param in params.iter().rev() {
|
||||||
function = function.lambda(param);
|
function = function.lambda(param);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We basically Scott encode our function bodies and use the chooser function
|
// We basically Scott encode our function bodies and use the chooser function
|
||||||
// to determine which function body and params is run
|
// to determine which function body and params is run
|
||||||
|
|
Loading…
Reference in New Issue