Handle simple aliased fn in params value def

This commit is contained in:
Agus Zubiaga 2024-08-27 01:25:59 -03:00
parent 6cffe9b1db
commit 36df43fadc
No known key found for this signature in database
6 changed files with 77 additions and 29 deletions

View file

@ -113,21 +113,35 @@ impl Annotation {
self
}
pub fn convert_to_fn(&mut self, argument_count: usize, var_store: &mut VarStore) {
let mut arg_types = Vec::with_capacity(argument_count);
pub fn add_arguments(&mut self, argument_count: usize, var_store: &mut VarStore) {
match self.signature {
Type::Function(ref mut arg_types, _, _) => {
arg_types.reserve(argument_count);
for _ in 0..argument_count {
let var = var_store.fresh();
self.introduced_variables.insert_inferred(Loc::at_zero(var));
for _ in 0..argument_count {
let var = var_store.fresh();
self.introduced_variables.insert_inferred(Loc::at_zero(var));
arg_types.push(Type::Variable(var));
arg_types.push(Type::Variable(var));
}
}
_ => {
let mut arg_types = Vec::with_capacity(argument_count);
for _ in 0..argument_count {
let var = var_store.fresh();
self.introduced_variables.insert_inferred(Loc::at_zero(var));
arg_types.push(Type::Variable(var));
}
self.signature = Type::Function(
arg_types,
Box::new(Type::Variable(var_store.fresh())),
Box::new(self.signature.clone()),
);
}
}
self.signature = Type::Function(
arg_types,
Box::new(Type::Variable(var_store.fresh())),
Box::new(self.signature.clone()),
);
}
}