diff --git a/nac3core/src/codegen/mod.rs b/nac3core/src/codegen/mod.rs index 923d4ee7..cb58f84d 100644 --- a/nac3core/src/codegen/mod.rs +++ b/nac3core/src/codegen/mod.rs @@ -726,6 +726,19 @@ pub fn gen_func_impl< let mut params = args .iter() .map(|arg| { + let base_ty = if arg.is_vararg { + let TypeEnum::TTuple { ty, is_vararg_ctx: true, .. } = + &*unifier.get_ty_immutable(arg.ty) + else { + unreachable!() + }; + debug_assert_eq!(ty.len(), 1); + + ty[0] + } else { + arg.ty + }; + get_llvm_abi_type( context, &module, @@ -734,7 +747,7 @@ pub fn gen_func_impl< top_level_ctx.as_ref(), &mut type_cache, &primitives, - arg.ty, + base_ty, ) .into() }) @@ -744,9 +757,11 @@ pub fn gen_func_impl< params.insert(0, ret_type.unwrap().ptr_type(AddressSpace::default()).into()); } + let is_vararg = args.iter().any(|arg| arg.is_vararg); + let fn_type = match ret_type { - Some(ret_type) if !has_sret => ret_type.fn_type(¶ms, false), - _ => context.void_type().fn_type(¶ms, false), + Some(ret_type) if !has_sret => ret_type.fn_type(¶ms, is_vararg), + _ => context.void_type().fn_type(¶ms, is_vararg), }; let symbol = &task.symbol_name;