{"record":{"id":"1a6d09e1efbf8634","repo":"slint-ui/slint","slug":"invalid-number-of-argument-for-callback","errorCode":null,"errorMessage":"invalid number of argument for callback {}::{}","messagePattern":"invalid number of argument for callback (.+?)::(.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compiler/generator/rust_live_preview.rs","lineNumber":120,"sourceCode":"                callback.args.iter().map(|a| rust_primitive_type(a).unwrap()).collect::<Vec<_>>();\n            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(#prop_name, &[#(#args_name.into(),)*])\n                        .try_into().unwrap_or_else(|_| panic!(\"Invalid return type for callback {}::{}\", #component_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_callback(#prop_name, sp::Rc::new(move |values| {\n                        let [#(#args_name,)*] = values else { panic!(\"invalid number of argument for callback {}::{}\", #component_name, #prop_name) };\n                        (*f.borrow_mut())(#(#args_name.clone().try_into().unwrap_or_else(|_| panic!(\"invalid argument for callback {}::{}\", #component_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(#prop_name, &[#(#args_name.into(),)*])\n                        .try_into().unwrap_or_else(|_| panic!(\"Invalid return type for function {}::{}\", #component_name, #prop_name))\n                }\n            ));","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/slint-ui/slint/blob/3fd8f2ec03c2aa8a95d5f4b9daa299c7b8bf4016/internal/compiler/generator/rust_live_preview.rs#L102-L138","documentation":"Error \"invalid number of argument for callback {}::{}\" thrown in slint-ui/slint.","triggerScenarios":"Thrown at internal/compiler/generator/rust_live_preview.rs:120 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Match the number of arguments in the Rust callback to the .slint declaration.","Re-run the live preview after changing the callback signature."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fd8f2ec03c2aa8a95d5f4b9daa299c7b8bf4016","analyzedAt":"2026-08-19T23:23:16.610Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}