Issue a warning when accessing a deprecated property through component scopes

This commit is contained in:
Simon Hausmann 2021-02-03 07:59:58 +01:00
parent c771bcff45
commit e8b64be9bd
3 changed files with 10 additions and 1 deletions

View file

@ -584,6 +584,9 @@ impl Expression {
let PropertyLookupResult { resolved_name, property_type } = let PropertyLookupResult { resolved_name, property_type } =
elem.borrow().lookup_property(&first_str); elem.borrow().lookup_property(&first_str);
if property_type.is_property_type() { if property_type.is_property_type() {
if resolved_name.as_ref() != &first_str {
ctx.diag.push_property_deprecation_warning(&first_str, &resolved_name, &first);
}
let prop = Self::PropertyReference(NamedReference { let prop = Self::PropertyReference(NamedReference {
element: Rc::downgrade(&elem), element: Rc::downgrade(&elem),
name: resolved_name.to_string(), name: resolved_name.to_string(),

View file

@ -20,4 +20,10 @@ Xxx := Rectangle {
duration: 250ms; duration: 250ms;
} }
} }
callback not_called;
not_called() => {
color = #000000;
// ^warning{The property 'color' has been deprecated. Please use 'background' instead}
}
} }

View file

@ -13,7 +13,7 @@ Xxx := Rectangle {
property <color> glop_col; property <color> glop_col;
property <string> blah: "yo"; property <string> blah: "yo";
plop(x, blah, hello) => { plop(x, blah, hello) => {
color = blah; background = blah;
x = 42 + hello; x = 42 + hello;
// ^error{Assignement need to be done on a property} // ^error{Assignement need to be done on a property}
width = x; width = x;