pola-rs/polars · error
expected an argument
Error message
expected an argument
What it means
Compile-time panic in the polars_expr proc macro (create_expression_function): a function argument in the decorated expression function is not a simple typed identifier pattern (syn::Pat::Ident), e.g. a tuple or destructuring pattern was used where a plain `name: Type` argument was expected.
Source
Thrown at pyo3-polars/pyo3-polars-derive/src/lib.rs:107
// Set latest error, but leave return value in empty state.
pyo3_polars::derive::_update_last_error(err);
},
})
}
fn create_expression_function(ast: syn::ItemFn) -> proc_macro2::TokenStream {
// count how often the user define a kwargs argument.
let args = ast
.sig
.inputs
.iter()
.skip(1)
.map(|fn_arg| {
if let FnArg::Typed(pat) = fn_arg {
if let syn::Pat::Ident(pat) = pat.pat.as_ref() {
pat.ident.to_string()
} else {
panic!("expected an argument")
}
} else {
panic!("expected a type argument")
}
})
.collect::<Vec<_>>();
let fn_name = &ast.sig.ident;
// Get the tokenstream of the call logic.
let quote_call = match args.len() {
0 => quote_call_no_kwargs(&ast, fn_name),
1 => match args[0].as_str() {
"kwargs" => quote_call_kwargs(&ast, fn_name),
"context" => quote_call_context(&ast, fn_name),
a => panic!("didn't expect argument {a}"),
},
2 => match (args[0].as_str(), args[1].as_str()) {View on GitHub (pinned to 9b5d73fd00)
Solutions
- Provide the required argument to the attribute, e.g. `#[polars_expr(output_type=...)]` with its argument.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at pyo3-polars/pyo3-polars-derive/src/lib.rs:107 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pola-rs/polars@9b5d73fd00 (2026-08-19).
Data as JSON: /api/errors/dd19cd1ff0d1d5e5.
Report an issue: GitHub.