mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-29 21:34:50 +00:00
Error when using a layout property outside of a layout
This commit is contained in:
parent
5b2add75e4
commit
733f44f50b
3 changed files with 21 additions and 4 deletions
|
@ -115,10 +115,12 @@ pub fn lower_layouts(component: &Rc<Component>, diag: &mut BuildDiagnostics) {
|
|||
});
|
||||
continue;
|
||||
} else {
|
||||
check_no_layout_properties(&child, diag);
|
||||
elem.children.push(child);
|
||||
}
|
||||
}
|
||||
});
|
||||
check_no_layout_properties(&component.root_element, diag);
|
||||
}
|
||||
|
||||
impl GridLayout {
|
||||
|
@ -170,3 +172,11 @@ fn eval_const_expr(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn check_no_layout_properties(item: &ElementRc, diag: &mut BuildDiagnostics) {
|
||||
for (prop, expr) in item.borrow().bindings.iter() {
|
||||
if matches!(prop.as_ref(), "col" | "row" | "colspan" | "rowspan") {
|
||||
diag.push_error(format!("{} used outside of a GridLayout", prop), expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,14 @@ X := Rectangle {
|
|||
Text{
|
||||
row: 200000; // that's actually bigger than 65535
|
||||
// ^error{'row' must be a positive integer}
|
||||
Rectangle { row: 3; }
|
||||
// ^error{row used outside of a GridLayout}
|
||||
}
|
||||
}
|
||||
|
||||
colspan: 3;
|
||||
//FIXME: error{colspan used outside of a layout}
|
||||
Text { colspan: 3; }
|
||||
// ^error{colspan used outside of a GridLayout}
|
||||
col: 3;
|
||||
// ^error{col used outside of a GridLayout}
|
||||
|
||||
}
|
|
@ -8,8 +8,10 @@
|
|||
|
||||
#[test]
|
||||
fn syntax_tests() -> std::io::Result<()> {
|
||||
if let Some(specific_test) =
|
||||
std::env::args().skip(1).skip_while(|arg| arg.starts_with("--") || arg == "main").next()
|
||||
if let Some(specific_test) = std::env::args()
|
||||
.skip(1)
|
||||
.skip_while(|arg| arg.starts_with("--") || arg == "syntax_tests")
|
||||
.next()
|
||||
{
|
||||
let mut path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
path.push("tests");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue