mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Handle aliases at call instead
This commit is contained in:
parent
b70d48fd33
commit
80770fae11
3 changed files with 126 additions and 98 deletions
|
@ -113,35 +113,21 @@ impl Annotation {
|
|||
self
|
||||
}
|
||||
|
||||
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);
|
||||
pub fn convert_to_fn(&mut self, argument_count: usize, var_store: &mut VarStore) {
|
||||
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));
|
||||
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));
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
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()),
|
||||
);
|
||||
}
|
||||
arg_types.push(Type::Variable(var));
|
||||
}
|
||||
|
||||
self.signature = Type::Function(
|
||||
arg_types,
|
||||
Box::new(Type::Variable(var_store.fresh())),
|
||||
Box::new(self.signature.clone()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3135,11 +3135,11 @@ impl Declarations {
|
|||
Index::push_new(&mut self.function_bodies, loc_function_def);
|
||||
|
||||
if let Some(annotation) = &mut self.annotations[index] {
|
||||
annotation.add_arguments(new_args_len, var_store);
|
||||
annotation.convert_to_fn(new_args_len, var_store);
|
||||
}
|
||||
|
||||
if let Some((_var, annotation)) = self.host_exposed_annotations.get_mut(&index) {
|
||||
annotation.add_arguments(new_args_len, var_store);
|
||||
annotation.convert_to_fn(new_args_len, var_store);
|
||||
}
|
||||
|
||||
self.declarations[index] = DeclarationTag::Function(function_def_index);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue