Fix zero-arg builtins invokations.

There are currently two zero-arg builtins:

  - mkNilData
  - mkNilPairData

  And while they have strictly speaking no arguments, the VM still
  requires that they are called with an extra unit argument applied.
This commit is contained in:
KtorZ
2024-07-27 11:31:40 +02:00
committed by Kasey
parent 1c58da4d86
commit 643e43f8aa
3 changed files with 144 additions and 20 deletions

View File

@@ -4066,10 +4066,16 @@ impl<'a> CodeGenerator<'a> {
builtin,
..
} => {
assert!(
builtin.is_none(),
"found remaining builtin function {func_name:?} ({builtin:?} declared as a module function in {module:?}"
);
if let Some(func) = builtin {
return self.gen_uplc(
Air::Builtin {
count: 0,
func: *func,
tipo: constructor.tipo,
},
arg_stack,
);
}
if let Some((names, index, cyclic_name)) = self.cyclic_functions.get(&(
FunctionAccessKey {
@@ -4490,8 +4496,12 @@ impl<'a> CodeGenerator<'a> {
term = builder::apply_builtin_forces(term, func.force_count());
for arg in arg_vec {
term = term.apply(arg.clone());
if func.arg_is_unit() {
term = term.apply(Term::unit())
} else {
for arg in arg_vec {
term = term.apply(arg.clone());
}
}
term