fix: found various unify and type issues while running tests

This commit is contained in:
microproofs
2024-03-29 13:00:39 -04:00
committed by Kasey
parent fd226be51f
commit 26f68c2fb4
5 changed files with 537 additions and 149 deletions

View File

@@ -695,13 +695,21 @@ pub fn pattern_has_conditions(
Pattern::Constructor {
arguments, tipo, ..
} => {
let data_type =
lookup_data_type_by_tipo(data_types, tipo).expect("Data type not found");
data_type.constructors.len() > 1
|| arguments
if tipo.is_pair()
|| (tipo.is_function() && tipo.return_type().map(|t| t.is_pair()).unwrap_or(false))
{
arguments
.iter()
.any(|arg| pattern_has_conditions(&arg.value, data_types))
} else {
let data_type = lookup_data_type_by_tipo(data_types, tipo)
.unwrap_or_else(|| panic!("Data type not found: {:#?}", tipo));
data_type.constructors.len() > 1
|| arguments
.iter()
.any(|arg| pattern_has_conditions(&arg.value, data_types))
}
}
Pattern::Assign { pattern, .. } => pattern_has_conditions(pattern, data_types),
Pattern::Var { .. } | Pattern::Discard { .. } => false,