fix: issue with modifying a functions dependencies and adding a function that depended on it causing infinite loops
This commit is contained in:
parent
a17ebf301f
commit
efb901f3b4
|
@ -2442,6 +2442,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
let mut arg_tipo = arg.tipo.clone();
|
let mut arg_tipo = arg.tipo.clone();
|
||||||
|
|
||||||
find_and_replace_generics(&mut arg_tipo, &mono_types);
|
find_and_replace_generics(&mut arg_tipo, &mono_types);
|
||||||
|
|
||||||
(index, arg_name, arg_tipo)
|
(index, arg_name, arg_tipo)
|
||||||
})
|
})
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
@ -2745,7 +2746,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
.collect_vec(),
|
.collect_vec(),
|
||||||
);
|
);
|
||||||
|
|
||||||
for func in dependency_vec {
|
for func in dependency_vec.into_iter() {
|
||||||
if self.defined_functions.contains_key(&func) {
|
if self.defined_functions.contains_key(&func) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2754,18 +2755,23 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
let mut added_dependencies = vec![];
|
let mut added_dependencies = vec![];
|
||||||
|
|
||||||
for same_scope_func in func_index_map
|
let Some(function_component) = function_definitions.get(&func)
|
||||||
.iter()
|
else {
|
||||||
.filter(|item| item.1 == func_scope && &func != item.0)
|
unreachable!("Function Definition should exist");
|
||||||
.map(|item| item.0)
|
};
|
||||||
{
|
|
||||||
added_dependencies.push(same_scope_func.clone());
|
if !function_component.args.is_empty() {
|
||||||
let same_scope_func_dependencies = function_definitions
|
for same_scope_func in func_index_map
|
||||||
.get(same_scope_func)
|
.iter()
|
||||||
.unwrap()
|
.filter(|item| item.1 == func_scope && &func != item.0)
|
||||||
.dependencies
|
.map(|item| item.0)
|
||||||
.clone();
|
{
|
||||||
added_dependencies.extend(same_scope_func_dependencies.iter().cloned())
|
if !self.defined_functions.contains_key(same_scope_func)
|
||||||
|
&& !final_func_dep_ir.contains_key(same_scope_func)
|
||||||
|
{
|
||||||
|
added_dependencies.push(same_scope_func.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let Some(function_component) = function_definitions.get_mut(&func)
|
let Some(function_component) = function_definitions.get_mut(&func)
|
||||||
|
@ -2774,7 +2780,6 @@ impl<'a> CodeGenerator<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
function_component.dependencies.extend(added_dependencies);
|
function_component.dependencies.extend(added_dependencies);
|
||||||
function_component.dependencies.dedup();
|
|
||||||
|
|
||||||
let function_component = function_definitions.get(&func).unwrap();
|
let function_component = function_definitions.get(&func).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -1442,8 +1442,12 @@ pub fn handle_func_dependencies(
|
||||||
) {
|
) {
|
||||||
let function_component = function_component.clone();
|
let function_component = function_component.clone();
|
||||||
|
|
||||||
let mut function_dependency_order = function_component.dependencies.clone();
|
let mut function_dependency_order = function_component
|
||||||
|
.dependencies
|
||||||
|
.iter()
|
||||||
|
.unique()
|
||||||
|
.cloned()
|
||||||
|
.collect_vec();
|
||||||
let mut dependency_map = IndexMap::new();
|
let mut dependency_map = IndexMap::new();
|
||||||
let mut dependency_vec = vec![];
|
let mut dependency_vec = vec![];
|
||||||
|
|
||||||
|
@ -1455,7 +1459,7 @@ pub fn handle_func_dependencies(
|
||||||
dependency_map.shift_remove(&dependency);
|
dependency_map.shift_remove(&dependency);
|
||||||
}
|
}
|
||||||
|
|
||||||
function_dependency_order.extend(depend_comp.dependencies.iter().cloned().collect_vec());
|
function_dependency_order.extend(depend_comp.dependencies.clone());
|
||||||
|
|
||||||
dependency_map.insert(dependency, ());
|
dependency_map.insert(dependency, ());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue