mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
Fix error messages with invalid change callback
This commit is contained in:
parent
36ccc9d658
commit
a63618fcfe
2 changed files with 47 additions and 1 deletions
|
@ -1363,7 +1363,24 @@ impl Element {
|
|||
}
|
||||
let Some(prop) = parser::identifier_text(&ch.DeclaredIdentifier()) else { continue };
|
||||
let lookup_result = r.lookup_property(&prop);
|
||||
if lookup_result.property_visibility == PropertyVisibility::Private
|
||||
if !lookup_result.is_valid() {
|
||||
diag.push_error(
|
||||
format!("Property '{prop}' does not exist"),
|
||||
&ch.DeclaredIdentifier(),
|
||||
);
|
||||
} else if !lookup_result.property_type.is_property_type() {
|
||||
let what = match lookup_result.property_type {
|
||||
Type::Function { .. } => "a function",
|
||||
Type::Callback { .. } => "a callback",
|
||||
_ => "not a property",
|
||||
};
|
||||
diag.push_error(
|
||||
format!(
|
||||
"Change callback can only be set on properties, and '{prop}' is {what}"
|
||||
),
|
||||
&ch.DeclaredIdentifier(),
|
||||
);
|
||||
} else if lookup_result.property_visibility == PropertyVisibility::Private
|
||||
&& !lookup_result.is_local_to_component
|
||||
{
|
||||
diag.push_error(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue