pola-rs/polars · error
expected a type argument
Error message
expected a type argument
What it means
Compile-time panic in the polars_expr proc macro: the function argument is not FnArg::Typed (e.g. a `self` receiver or malformed input), so no type annotation can be extracted for the generated expression wrapper.
Source
Thrown at pyo3-polars/pyo3-polars-derive/src/lib.rs:110
})
}
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()) {
("context", "kwargs") => quote_call_context_kwargs(&ast, fn_name),
("kwargs", "context") => panic!("'kwargs', 'context' order should be reversed"),
(a, b) => panic!("didn't expect arguments {a}, {b}"),View on GitHub (pinned to 9b5d73fd00)
Solutions
- Provide a type argument, e.g. `#[polars_expr(output_type_func=...)]` with a type where one is expected.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at pyo3-polars/pyo3-polars-derive/src/lib.rs:110 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/f70d10551146f728.
Report an issue: GitHub.