{"record":{"id":"a16edef70b563893","repo":"slint-ui/slint","slug":"invalid-argument-for-callback","errorCode":null,"errorMessage":"invalid argument for callback {}::{}","messagePattern":"invalid argument for callback (.+?)::(.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compiler/generator/rust_live_preview.rs","lineNumber":289,"sourceCode":"            let return_type = rust_primitive_type(&callback.return_type).unwrap();\n            let args_name =\n                (0..callback.args.len()).map(|i| format_ident!(\"arg_{}\", i)).collect::<Vec<_>>();\n            let caller_ident = accessor_names::rust_accessor_ident(name, AccessorKind::Invoker);\n            property_and_callback_accessors.push(quote!(\n                #[allow(dead_code)]\n                pub fn #caller_ident(&self, #(#args_name : #callback_args,)*) -> #return_type {\n                    self.0.borrow().invoke_global(#global_name, #prop_name, &[#(#args_name.into(),)*])\n                        .try_into().unwrap_or_else(|_| panic!(\"Invalid return type for callback {}::{}\", #global_name, #prop_name))\n                }\n            ));\n            let on_ident = accessor_names::rust_accessor_ident(name, AccessorKind::Handler);\n            property_and_callback_accessors.push(quote!(\n                #[allow(dead_code)]\n                pub fn #on_ident(&self, f: impl FnMut(#(#callback_args),*) -> #return_type + 'static) {\n                    let f = ::core::cell::RefCell::new(f);\n                    self.0.borrow().set_global_callback(#global_name, #prop_name, sp::Rc::new(move |values| {\n                        let [#(#args_name,)*] = values else { panic!(\"invalid number of argument for callback {}::{}\", #global_name, #prop_name) };\n                        (*f.borrow_mut())(#(#args_name.clone().try_into().unwrap_or_else(|_| panic!(\"invalid argument for callback {}::{}\", #global_name, #prop_name)),)*).into()\n                    }))\n                }\n            ));\n        } else if let Type::Function(function) = &p.ty {\n            let callback_args =\n                function.args.iter().map(|a| rust_primitive_type(a).unwrap()).collect::<Vec<_>>();\n            let return_type = rust_primitive_type(&function.return_type).unwrap();\n            let args_name =\n                (0..function.args.len()).map(|i| format_ident!(\"arg_{}\", i)).collect::<Vec<_>>();\n            let caller_ident = accessor_names::rust_accessor_ident(name, AccessorKind::Invoker);\n            property_and_callback_accessors.push(quote!(\n                #[allow(dead_code)]\n                pub fn #caller_ident(&self, #(#args_name : #callback_args,)*) -> #return_type {\n                    self.0.borrow().invoke_global(#global_name, #prop_name, &[#(#args_name.into(),)*])\n                        .try_into().unwrap_or_else(|_| panic!(\"Invalid return type for function {}::{}\", #global_name, #prop_name))\n                }\n            ));\n        } else {","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/compiler/generator/rust_live_preview.rs#L271-L307","documentation":"Same site as the arity check, but this panic is the unwrap failure on the individual pieces: either a callback argument type or the return type had no mapping in rust_primitive_type, so no Rust type could be produced for the generated invoker accessor. It means the live-preview generator encountered a callback signature (in a global) containing a type it cannot express in generated Rust.","triggerScenarios":"Thrown at internal/compiler/generator/rust_live_preview.rs:285 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Extend rust_primitive_type to map the callback's argument or return type (e.g. structs, models, enums) to a Rust primitive type","Simplify the .slint callback signature to use only types the live-preview generator supports","Check the callback return type first: the unwrap on rust_primitive_type(&callback.return_type) is the usual offender"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}