fix: function hoisting errors --
One involving zero args being hoisted instead of compiled and replaced. Second involving not updating a function's dependeny function scope. Which then hoisted to a lower scope and caused free unique
This commit is contained in:
parent
703429af98
commit
822bb4242a
|
@ -2522,7 +2522,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
if dependency_map.contains_key(&function.0) {
|
if dependency_map.contains_key(&function.0) {
|
||||||
dependency_map.shift_remove(&function.0);
|
dependency_map.shift_remove(&function.0);
|
||||||
}
|
}
|
||||||
dependency_map.insert(function.0, function.1);
|
|
||||||
func_keys.extend(
|
func_keys.extend(
|
||||||
funct_comp
|
funct_comp
|
||||||
.dependencies
|
.dependencies
|
||||||
|
@ -2535,6 +2535,15 @@ impl<'a> CodeGenerator<'a> {
|
||||||
})
|
})
|
||||||
.collect_vec(),
|
.collect_vec(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let func_scope = func_index_map.get(&function.0).unwrap().clone();
|
||||||
|
|
||||||
|
for dep in funct_comp.dependencies.iter() {
|
||||||
|
let Some(dep_scope) = func_index_map.get_mut(dep) else { unreachable!("Missing dependency scope.")};
|
||||||
|
|
||||||
|
*dep_scope = dep_scope.common_ancestor(&func_scope);
|
||||||
|
}
|
||||||
|
dependency_map.insert(function.0, function.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
dependency_vec.extend(
|
dependency_vec.extend(
|
||||||
|
@ -2816,9 +2825,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
for (index, ir) in ir_stack.to_vec().iter().enumerate().rev() {
|
for (index, ir) in ir_stack.to_vec().iter().enumerate().rev() {
|
||||||
match ir {
|
match ir {
|
||||||
Air::Var {
|
Air::Var {
|
||||||
scope,
|
scope, constructor, ..
|
||||||
constructor,
|
|
||||||
..
|
|
||||||
} => {
|
} => {
|
||||||
if let ValueConstructorVariant::ModuleFn {
|
if let ValueConstructorVariant::ModuleFn {
|
||||||
name,
|
name,
|
||||||
|
|
|
@ -1473,7 +1473,7 @@ pub fn handle_func_dependencies(
|
||||||
|
|
||||||
let dep_scope = func_index_map.get(&dependency).unwrap();
|
let dep_scope = func_index_map.get(&dependency).unwrap();
|
||||||
|
|
||||||
if dep_scope.common_ancestor(func_scope) == *func_scope
|
if (dep_scope.common_ancestor(func_scope) == *func_scope && !depend_comp.args.is_empty())
|
||||||
|| function_component.args.is_empty()
|
|| function_component.args.is_empty()
|
||||||
{
|
{
|
||||||
let mut recursion_ir = vec![];
|
let mut recursion_ir = vec![];
|
||||||
|
|
Loading…
Reference in New Issue