mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
Improve error message when a callback clashes with a property
(also continue, don't declare the the callback anyway)
This commit is contained in:
parent
6d29a66b52
commit
e6bd9dc8c4
2 changed files with 19 additions and 7 deletions
|
@ -854,17 +854,25 @@ impl Element {
|
|||
..
|
||||
} = r.lookup_property(&name);
|
||||
if !matches!(maybe_existing_prop_type, Type::Invalid) {
|
||||
if r.property_declarations.contains_key(&name) {
|
||||
diag.push_error(
|
||||
"Duplicated callback declaration".into(),
|
||||
&sig_decl.DeclaredIdentifier(),
|
||||
);
|
||||
if matches!(maybe_existing_prop_type, Type::Callback { .. }) {
|
||||
if r.property_declarations.contains_key(&name) {
|
||||
diag.push_error(
|
||||
"Duplicated callback declaration".into(),
|
||||
&sig_decl.DeclaredIdentifier(),
|
||||
);
|
||||
} else {
|
||||
diag.push_error(
|
||||
format!("Cannot override callback '{}'", existing_name),
|
||||
&sig_decl.DeclaredIdentifier(),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
diag.push_error(
|
||||
format!("Cannot override callback '{}'", existing_name),
|
||||
format!("Cannot declare callback '{}' when a property with the same name exists", existing_name),
|
||||
&sig_decl.DeclaredIdentifier(),
|
||||
)
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
let args = sig_decl.Type().map(|node_ty| type_from_node(node_ty, diag, tr)).collect();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue