{"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":288,"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_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            ));","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/compiler/generator/rust_live_preview.rs#L270-L306","documentation":"In the live-preview Rust generator, global callback invoker accessors are generated from the callback signature; rust_primitive_type is unwrapped with a plain unwrap on each argument type, and this panic message reports the mismatch when the number of generated argument idents doesn't line up with the callback's declared args. It indicates the generated code assumed a fixed arity or an untranslatable argument type for the global's callback — an internal codegen invariant violation, not a user .slint error per se.","triggerScenarios":"Thrown at internal/compiler/generator/rust_live_preview.rs:284 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the callback declaration in the .slint global: the number of declared args must match what rust_primitive_type can map one-for-one","Fix rust_primitive_type to return Some for each arg type; a None for one arg triggers this error since generate_global unwraps the mapped list length","If a callback intentionally has zero or many args, ensure the codegen path (generated invoker signature) handles that count"],"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"}