{"record":{"id":"7a6a30cd92299ab5","repo":"slint-ui/slint","slug":"invalid-type-in-public-properties-cpp-live-preview","errorCode":null,"errorMessage":"Invalid type in public properties","messagePattern":"Invalid type in public properties","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compiler/generator/cpp_live_preview.rs","lineNumber":379,"sourceCode":"            )];\n            declarations.push((\n                Access::Public,\n                Declaration::Function(Function {\n                    name: accessor_names::cpp_accessor_name(prop_name, AccessorKind::Invoker),\n                    signature: format!(\n                        \"({}) const -> {ret}\",\n                        param_types\n                            .iter()\n                            .enumerate()\n                            .map(|(i, ty)| format!(\"{ty} arg_{i}\"))\n                            .join(\", \"),\n                    ),\n                    statements: Some(call_code),\n                    ..Default::default()\n                }),\n            ));\n        } else {\n            let cpp_property_type = p.ty.cpp_type().expect(\"Invalid type in public properties\");\n            let prop_getter: Vec<String> = vec![format!(\n                \"return {}(live_preview.get_property(\\\"{prefix}{prop_name}\\\"));\",\n                convert_from_value_fn(&p.ty)\n            )];\n            declarations.push((\n                Access::Public,\n                Declaration::Function(Function {\n                    name: accessor_names::cpp_accessor_name(prop_name, AccessorKind::Getter),\n                    signature: format!(\"() const -> {cpp_property_type}\"),\n                    statements: Some(prop_getter),\n                    ..Default::default()\n                }),\n            ));\n\n            if !p.read_only() {\n                let prop_setter: Vec<String> = vec![\n                    \"using slint::private_api::live_preview::into_slint_value;\".into(),\n                    format!(","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/compiler/generator/cpp_live_preview.rs#L361-L397","documentation":"In `cpp_live_preview.rs`, the live-preview public API generator maps each public property's Slint type to a C++ type via `cpp_type()`; a None result panics. This is the live-preview variant of the public-property type check: every type exposed on the generated live-preview facade must have a C++ representation and a value-conversion function.","triggerScenarios":"`generate_public_api_for_properties` (called from `generate_public_component` or `generate_global`) encounters a public property whose type lacks a `cpp_type()` mapping, or whose `convert_from_value_fn` counterpart is also missing for the live-preview value path.","commonSituations":"Adding a new Slint builtin type without updating the C++/live-preview mappings; exposing internal-only types (layout constraints, native structs) as public properties; generated code from a newer compiler consumed by an older generator.","solutions":["Add the missing mapping in `Type::cpp_type()` (and `convert_from_value_fn` for the live preview)","Change the property type in the .slint source to a C++-supported type or make it non-public","Turn the expect into a proper diagnostic that names the property and type"],"exampleFix":"// before\nlet cpp_property_type = p.ty.cpp_type().expect(\"Invalid type in public properties\");\n// after\nlet cpp_property_type = p.ty.cpp_type().unwrap_or_else(||\n    panic!(\"public property '{prop_name}' has C++-unsupported type {:?}\", p.ty));","handlingStrategy":"validation","validationCode":"fn check_live_preview_property(name: &str, ty: &Type) {\n    assert!(ty.cpp_type().is_some(), \"'{name}': type {ty:?} unsupported in live-preview public API\");\n}","typeGuard":"fn cpp_type_of(ty: &Type) -> Option<String> {\n    ty.cpp_type().map(|t| t.to_string())\n}","tryCatchPattern":null,"preventionTips":["Map new types in both cpp_type() and convert_from_value_fn","Only declare public properties with C++-supported types in .slint","Add a generator test enumerating all supported property types","Fail with a named-property diagnostic instead of a bare expect"],"tags":["compiler","cpp-codegen","live-preview","type-system"],"backgroundTag":"type-mismatch","analyzedSha":"3a7e700487dc74d404cad0726378053ab763d4e0","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}