{"record":{"id":"b9a97c7adfbf875d","repo":"pola-rs/polars","slug":"didn-t-expect-arguments-a-b","errorCode":null,"errorMessage":"didn't expect arguments {a}, {b}","messagePattern":"didn't expect arguments (.+?), (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pyo3-polars/pyo3-polars-derive/src/lib.rs","lineNumber":128,"sourceCode":"                panic!(\"expected a type argument\")\n            }\n        })\n        .collect::<Vec<_>>();\n\n    let fn_name = &ast.sig.ident;\n\n    // Get the tokenstream of the call logic.\n    let quote_call = match args.len() {\n        0 => quote_call_no_kwargs(&ast, fn_name),\n        1 => match args[0].as_str() {\n            \"kwargs\" => quote_call_kwargs(&ast, fn_name),\n            \"context\" => quote_call_context(&ast, fn_name),\n            a => panic!(\"didn't expect argument {a}\"),\n        },\n        2 => match (args[0].as_str(), args[1].as_str()) {\n            (\"context\", \"kwargs\") => quote_call_context_kwargs(&ast, fn_name),\n            (\"kwargs\", \"context\") => panic!(\"'kwargs', 'context' order should be reversed\"),\n            (a, b) => panic!(\"didn't expect arguments {a}, {b}\"),\n        },\n        _ => panic!(\"didn't expect so many arguments\"),\n    };\n\n    let quote_process_result = quote_process_results();\n    let fn_name = get_expression_function_name(fn_name);\n\n    quote!(\n        use ::pyo3_polars::export::*;\n\n        // create the outer public function\n        #[no_mangle]\n        pub unsafe extern \"C\" fn #fn_name (\n            e: *mut polars_ffi::version_0::SeriesExport,\n            input_len: usize,\n            kwargs_ptr: *const u8,\n            kwargs_len: usize,\n            return_value: *mut polars_ffi::version_0::SeriesExport,","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/pyo3-polars/pyo3-polars-derive/src/lib.rs#L110-L146","documentation":"The two-argument arm accepts only (\"context\", \"kwargs\"); any other name pair hits panic!(\"didn't expect arguments {a}, {b}\") (lib.rs:128). This is the compile-time guard ensuring polars_expr functions use only the recognized special-parameter combinations.","triggerScenarios":"Declaring a #[polars_expr] function with two parameters not exactly named context and kwargs in that order — e.g. (a, b), (series, kwargs), (kwargs, other).","commonSituations":"Trying to pass two typed Series parameters directly; inventing custom parameter names for the special two-arg protocol.","solutions":["Rename the parameters to exactly (context, kwargs) if you need both special inputs.","Otherwise move extra inputs into the kwargs struct and keep only Series/typed parameters plus the kwargs parameter per your version's convention.","Consult pyo3-polars-derive docs for the allowed parameter-name combos: (), (kwargs), (context), (context, kwargs)."],"exampleFix":"// before\nfn f(series: &Series, opts: Wrapped<Kw>) -> ...\n// after\nfn f(context: &Context, kwargs: Wrapped<Kw>) -> ...","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only the recognized two-parameter combo (context, kwargs).","Route other inputs through the kwargs struct instead of adding parameters."],"tags":["proc-macro","compile-time","argument-order","rust"],"backgroundTag":"invalid-argument-format","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}