change check_validator_args to check type after each arg
This commit is contained in:
parent
6c6be3f53d
commit
056e3d76ea
|
@ -2751,18 +2751,24 @@ impl<'a> CodeGenerator<'a> {
|
|||
) -> AirTree {
|
||||
let mut arg_names = vec![];
|
||||
|
||||
let checked_args =
|
||||
arguments
|
||||
.iter()
|
||||
.enumerate()
|
||||
.rev()
|
||||
.fold(body, |inner_then, (index, arg)| {
|
||||
.with_position()
|
||||
.fold(body, |inner_then, arg_position| match arg_position {
|
||||
itertools::Position::First(arg) if has_context => {
|
||||
let arg_name = arg.arg_name.get_variable_name().unwrap_or("_").to_string();
|
||||
|
||||
AirTree::anon_func(vec![arg_name], inner_then)
|
||||
}
|
||||
itertools::Position::First(arg)
|
||||
| itertools::Position::Middle(arg)
|
||||
| itertools::Position::Last(arg) => {
|
||||
let arg_name = arg.arg_name.get_variable_name().unwrap_or("_").to_string();
|
||||
let arg_span = arg.location;
|
||||
|
||||
arg_names.push(arg_name.clone());
|
||||
|
||||
if !(has_context && index == arguments.len() - 1) && &arg_name != "_" {
|
||||
let param = AirTree::local_var(&arg_name, data());
|
||||
|
||||
let actual_type = convert_opaque_type(&arg.tipo, &self.data_types);
|
||||
|
@ -2796,7 +2802,7 @@ impl<'a> CodeGenerator<'a> {
|
|||
}
|
||||
};
|
||||
|
||||
self.assignment(
|
||||
let inner_then = self.assignment(
|
||||
&Pattern::Var {
|
||||
location: Span::empty(),
|
||||
name: arg_name.to_string(),
|
||||
|
@ -2811,15 +2817,12 @@ impl<'a> CodeGenerator<'a> {
|
|||
full_check: true,
|
||||
msg_func,
|
||||
},
|
||||
)
|
||||
} else {
|
||||
inner_then
|
||||
);
|
||||
|
||||
AirTree::anon_func(vec![arg_name], inner_then)
|
||||
}
|
||||
});
|
||||
|
||||
arg_names.reverse();
|
||||
|
||||
AirTree::anon_func(arg_names, checked_args)
|
||||
itertools::Position::Only(_) => unreachable!(),
|
||||
})
|
||||
}
|
||||
|
||||
fn hoist_functions_to_validator(&mut self, mut air_tree: AirTree) -> AirTree {
|
||||
|
|
Loading…
Reference in New Issue