test: add acceptance test 86

fix: prevent mutual recursion for expect type code gen functions
This commit is contained in:
microproofs
2023-07-04 12:24:25 -04:00
parent 841547dd6c
commit 67c072a1a9
7 changed files with 96 additions and 2 deletions

View File

@@ -19,7 +19,7 @@ use crate::{
builtins::{bool, data, void},
expr::TypedExpr,
gen_uplc::builder::{
find_and_replace_generics, get_generic_id_and_type, get_variant_name,
find_and_replace_generics, get_arg_type_name, get_generic_id_and_type, get_variant_name,
lookup_data_type_by_tipo,
},
tipo::{
@@ -2533,7 +2533,11 @@ impl<'a> CodeGenerator<'a> {
let mut func_stack = expect_stack.empty_with_scope();
let mut call_stack = expect_stack.empty_with_scope();
let mut data_type_variant = String::new();
let mut data_type_variant = tipo
.get_inner_types()
.iter()
.map(|arg| get_arg_type_name(arg))
.join("_");
if let Some(types) = tipo.arg_types() {
for mut tipo in types {

View File

@@ -2029,3 +2029,15 @@ pub fn special_case_builtin(
_ => unreachable!(),
}
}
pub fn get_arg_type_name(tipo: &Type) -> String {
match tipo {
Type::App { name, .. } => name.clone(),
Type::Var { tipo } => match tipo.borrow().clone() {
TypeVar::Link { tipo } => get_arg_type_name(tipo.as_ref()),
_ => unreachable!(),
},
Type::Tuple { .. } => "".to_string(),
_ => unreachable!(),
}
}