slint-ui/slint · error

Invalid property type for

Error message

Invalid property type for {}::{}

What it means

This panic comes from a generated property getter accessor in the Rust live-preview code generator. `get_global_property` returns the property's runtime `Value`, which is then converted with `convert_from_value`; if the Value does not match the property's declared type, the conversion returns Err and the code panics. It signals that the property's runtime value type diverges from its declared type in the generated accessor.

Solutions

  1. Regenerate the live-preview Rust accessors so they match the current .slint global property declarations
  2. Verify the global property's declared type in the .slint file matches how the accessor was generated
  3. Initialize the global property to a value of the declared type before reading it

Example fix

// before (accessor generated for bool while property is now string)
pub fn get_label(&self) -> bool { convert_from_value_bool(self.0.borrow().get_global_property(...)).unwrap_or_else(|_| panic!("Invalid property type for {}::{}", ...)) }
// after (regenerated accessor matching the current declaration)
pub fn get_label(&self) -> SharedString { convert_from_value_string(self.0.borrow().get_global_property(...)).unwrap_or_else(|_| panic!("Invalid property type for {}::{}", ...)) }
Defensive patterns

Strategy: fallback

Try / catch

// panic in generated code; avoid by regenerating accessors when property types change

Prevention

When it happens

Trigger: Calling a generated getter (e.g. `get_my_prop()`) for a global property whose value in the interpreter instance is not of the declared type — e.g. after a live-reload changed the property type, or the property was never assigned and its default differs from the accessor's assumed type.

Common situations: Hot-reload/live-preview sessions where a global property type was edited while generated Rust bindings remained stale; accessing globals from previewed components whose compiled model differs from the generated code.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of slint-ui/slint@3a7e700487 (2026-09-16). Data as JSON: /api/errors/eb943b644a79e0c6. Report an issue: GitHub.

Appendix: source

Thrown at internal/compiler/generator/rust_live_preview.rs:317

            let caller_ident = accessor_names::rust_accessor_ident(name, AccessorKind::Invoker);
            property_and_callback_accessors.push(quote!(
                #[allow(dead_code)]
                pub fn #caller_ident(&self, #(#args_name : #callback_args,)*) -> #return_type {
                    self.0.borrow().invoke_global(#global_name, #prop_name, &[#(#args_name.into(),)*])
                        .try_into().unwrap_or_else(|_| panic!("Invalid return type for function {}::{}", #global_name, #prop_name))
                }
            ));
        } else {
            let rust_property_type = rust_primitive_type(&p.ty).unwrap();
            let convert_to_value = convert_to_value_fn(&p.ty);
            let convert_from_value = convert_from_value_fn(&p.ty);

            let getter_ident = accessor_names::rust_accessor_ident(name, AccessorKind::Getter);
            property_and_callback_accessors.push(quote!(
                #[allow(dead_code)]
                pub fn #getter_ident(&self) -> #rust_property_type {
                    #convert_from_value(self.0.borrow().get_global_property(#global_name, #prop_name))
                        .unwrap_or_else(|_| panic!("Invalid property type for {}::{}", #global_name, #prop_name))
                }
            ));

            let setter_ident = accessor_names::rust_accessor_ident(name, AccessorKind::Setter);
            if !p.read_only() {
                property_and_callback_accessors.push(quote!(
                    #[allow(dead_code)]
                    pub fn #setter_ident(&self, value: #rust_property_type) {
                        self.0.borrow().set_global_property(#global_name, #prop_name, #convert_to_value(value))
                    }
                ));
            } else {
                property_and_callback_accessors.push(quote!(
                    #[allow(dead_code)] fn #setter_ident(&self, _read_only_property : ()) { }
                ));
            }
        }
    }

View on GitHub (pinned to 3a7e700487)