Fixed property in when assign validation.
This commit is contained in:
parent
f0357964a4
commit
d35878415c
|
@ -1,5 +1,7 @@
|
|||
# Widget & Property Refactor
|
||||
|
||||
* Refactor `defaults!` and `properties!` to be proc-macros directly.
|
||||
- The `macro_rules!` indirection causes the error span to be inside the macro instead of the call site..
|
||||
* Refactor `#[widget]`.
|
||||
- Test build error for parent not a widget.
|
||||
- Where is `widget_new!` available for the widget macro?
|
||||
|
|
|
@ -335,12 +335,12 @@ impl MultiWhenWgt {
|
|||
fn on_start(&mut self) {
|
||||
defaults! {
|
||||
self;
|
||||
util::trace = "default";
|
||||
util::live_trace = "default";
|
||||
when *#util::is_state {
|
||||
util::trace = "state_0";
|
||||
util::live_trace = "state_0";
|
||||
}
|
||||
when *#util::is_state {
|
||||
util::trace = "state_1";
|
||||
util::live_trace = "state_1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -599,6 +599,20 @@ fn prop_assign(prop: &WgtProperty, errors: &mut Errors, is_when: bool) -> TokenS
|
|||
}
|
||||
}
|
||||
|
||||
let ident_meta = ident_spanned!(ident.span()=> "{}_meta__", ident);
|
||||
|
||||
let when_check = if is_when {
|
||||
let meta = quote_call!(#ident_meta());
|
||||
quote! {
|
||||
{
|
||||
let meta__ = #meta
|
||||
meta__.allowed_in_when_assign();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
quote!()
|
||||
};
|
||||
|
||||
let prop_init;
|
||||
|
||||
match &prop.value {
|
||||
|
@ -625,7 +639,6 @@ fn prop_assign(prop: &WgtProperty, errors: &mut Errors, is_when: bool) -> TokenS
|
|||
let idents = fields.iter().map(|f| &f.ident);
|
||||
let values = fields.iter().map(|f| &f.expr);
|
||||
let ident_sorted = ident_spanned!(ident.span()=> "{}_sorted__", ident);
|
||||
let ident_meta = ident_spanned!(ident.span()=> "{}_meta__", ident);
|
||||
|
||||
let call = quote_call! {
|
||||
#ident_sorted(#(#idents_sorted),*)
|
||||
|
@ -665,6 +678,7 @@ fn prop_assign(prop: &WgtProperty, errors: &mut Errors, is_when: bool) -> TokenS
|
|||
|
||||
quote! {
|
||||
#attrs {
|
||||
#when_check
|
||||
#custom_expand
|
||||
#prop_init
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue