mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
compiler: Fix infinite recursion trying to inline function argument
We can't use `body.visit_recursive_mut` because it will recurse on the newly replaced argument. Implement recursion manually instead.
This commit is contained in:
parent
9f91a60ca7
commit
a3ab90d4fc
2 changed files with 52 additions and 6 deletions
|
@ -263,14 +263,17 @@ fn try_inline_function(function: &Callable, arguments: &[Expression]) -> Option<
|
|||
}
|
||||
let mut body = extract_constant_property_reference(function)?;
|
||||
|
||||
body.visit_recursive_mut(&mut |e| {
|
||||
fn substitute_arguments_recursive(e: &mut Expression, arguments: &[Expression]) {
|
||||
if let Expression::FunctionParameterReference { index, ty } = e {
|
||||
let Some(e_new) = arguments.get(*index).cloned() else { return };
|
||||
if e_new.ty() == *ty {
|
||||
*e = e_new;
|
||||
}
|
||||
let e_new = arguments.get(*index).expect("reference to invalid arg").clone();
|
||||
debug_assert_eq!(e_new.ty(), *ty);
|
||||
*e = e_new;
|
||||
} else {
|
||||
e.visit_mut(|e| substitute_arguments_recursive(e, arguments));
|
||||
}
|
||||
});
|
||||
}
|
||||
substitute_arguments_recursive(&mut body, arguments);
|
||||
|
||||
if simplify_expression(&mut body) {
|
||||
Some(body)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue