mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Forbid usage of @children in repeated or conditional element
It leads to compiler panic, or errors in the generated code.
This commit is contained in:
parent
01d666083f
commit
53090ab489
2 changed files with 34 additions and 2 deletions
|
@ -953,22 +953,36 @@ impl Element {
|
|||
tr,
|
||||
));
|
||||
} else if se.kind() == SyntaxKind::RepeatedElement {
|
||||
let mut sub_child_insertion_point = None;
|
||||
let rep = Element::from_repeated_node(
|
||||
se.into(),
|
||||
&r,
|
||||
component_child_insertion_point,
|
||||
&mut sub_child_insertion_point,
|
||||
diag,
|
||||
tr,
|
||||
);
|
||||
if let Some((_, se)) = sub_child_insertion_point {
|
||||
diag.push_error(
|
||||
"The @children placeholder cannot appear in a repeated element".into(),
|
||||
&se,
|
||||
)
|
||||
}
|
||||
r.borrow_mut().children.push(rep);
|
||||
} else if se.kind() == SyntaxKind::ConditionalElement {
|
||||
let mut sub_child_insertion_point = None;
|
||||
let rep = Element::from_conditional_node(
|
||||
se.into(),
|
||||
r.borrow().base_type.clone(),
|
||||
component_child_insertion_point,
|
||||
&mut sub_child_insertion_point,
|
||||
diag,
|
||||
tr,
|
||||
);
|
||||
if let Some((_, se)) = sub_child_insertion_point {
|
||||
diag.push_error(
|
||||
"The @children placeholder cannot appear in a conditional element".into(),
|
||||
&se,
|
||||
)
|
||||
}
|
||||
r.borrow_mut().children.push(rep);
|
||||
} else if se.kind() == SyntaxKind::ChildrenPlaceholder {
|
||||
if children_placeholder.is_some() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue