From e8b64be9bd28761aacd6826209fd51dc71f5dcdf Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 3 Feb 2021 07:59:58 +0100 Subject: [PATCH] Issue a warning when accessing a deprecated property through component scopes --- sixtyfps_compiler/passes/resolving.rs | 3 +++ .../tests/syntax/lookup/deprecated_property.60 | 6 ++++++ sixtyfps_compiler/tests/syntax/lookup/signal_arg.60 | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sixtyfps_compiler/passes/resolving.rs b/sixtyfps_compiler/passes/resolving.rs index 982a180aa..e1e877a4a 100644 --- a/sixtyfps_compiler/passes/resolving.rs +++ b/sixtyfps_compiler/passes/resolving.rs @@ -584,6 +584,9 @@ impl Expression { let PropertyLookupResult { resolved_name, property_type } = elem.borrow().lookup_property(&first_str); 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 { element: Rc::downgrade(&elem), name: resolved_name.to_string(), diff --git a/sixtyfps_compiler/tests/syntax/lookup/deprecated_property.60 b/sixtyfps_compiler/tests/syntax/lookup/deprecated_property.60 index 9fa0ba97a..56a9b4971 100644 --- a/sixtyfps_compiler/tests/syntax/lookup/deprecated_property.60 +++ b/sixtyfps_compiler/tests/syntax/lookup/deprecated_property.60 @@ -20,4 +20,10 @@ Xxx := Rectangle { duration: 250ms; } } + + callback not_called; + not_called() => { + color = #000000; +// ^warning{The property 'color' has been deprecated. Please use 'background' instead} + } } diff --git a/sixtyfps_compiler/tests/syntax/lookup/signal_arg.60 b/sixtyfps_compiler/tests/syntax/lookup/signal_arg.60 index c244e0a5a..3774915f4 100644 --- a/sixtyfps_compiler/tests/syntax/lookup/signal_arg.60 +++ b/sixtyfps_compiler/tests/syntax/lookup/signal_arg.60 @@ -13,7 +13,7 @@ Xxx := Rectangle { property glop_col; property blah: "yo"; plop(x, blah, hello) => { - color = blah; + background = blah; x = 42 + hello; // ^error{Assignement need to be done on a property} width = x;