fix: infer validator args as Data if Unbound closes #649

This commit is contained in:
rvcas
2023-07-11 13:51:17 -04:00
parent b80c41b4b7
commit 914b8d4e74

View File

@@ -319,7 +319,17 @@ fn infer_definition(
});
}
let typed_params = typed_fun.arguments.drain(0..params_length).collect();
let typed_params = typed_fun.arguments
.drain(0..params_length)
.map(|mut arg| {
if arg.tipo.is_unbound() {
arg.tipo = builtins::data();
}
arg
})
.collect();
if typed_fun.arguments.len() < 2 || typed_fun.arguments.len() > 3 {
return Err(Error::IncorrectValidatorArity {
@@ -328,6 +338,12 @@ fn infer_definition(
});
}
for arg in typed_fun.arguments.iter_mut() {
if arg.tipo.is_unbound() {
arg.tipo = builtins::data();
}
}
let typed_other_fun = other_fun
.map(|mut other| -> Result<TypedFunction, Error> {
let params = params.into_iter().chain(other.arguments);
@@ -372,10 +388,18 @@ fn infer_definition(
});
}
for arg in other_typed_fun.arguments.iter_mut() {
if arg.tipo.is_unbound() {
arg.tipo = builtins::data();
}
}
Ok(other_typed_fun)
})
.transpose();
Ok(Definition::Validator(Validator {
doc,
end_position,