Compiler: Don't panic when a Row is repeated in a GridLayout

Fixes #3729
This commit is contained in:
Olivier Goffart 2023-10-23 15:53:24 +02:00 committed by Olivier Goffart
parent 49571c8bf2
commit ae4debafe2
2 changed files with 28 additions and 1 deletions

View file

@ -98,7 +98,20 @@ fn lower_element_layout(
return;
};
match base_type.name.as_str() {
"Row" => panic!("Error caught at element lookup time"),
"Row" => {
// We shouldn't lower layout if we have a Row in there. Unless the Row is the root of a repeated item,
// in which case another error has been reported
assert!(
diag.has_error()
&& Rc::ptr_eq(&component.root_element, elem)
&& component
.parent_element
.upgrade()
.map_or(false, |e| e.borrow().repeated.is_some()),
"Error should have been caught at element lookup time"
);
return;
}
"GridLayout" => lower_grid_layout(component, elem, diag),
"HorizontalLayout" => lower_box_layout(elem, diag, Orientation::Horizontal),
"VerticalLayout" => lower_box_layout(elem, diag, Orientation::Vertical),