pola-rs/polars · error

didn't expect so many arguments

Error message

didn't expect so many arguments

What it means

Panic in the polars proc-macro attribute parser: the #[polars_expr]-style attribute was given more arguments (or an unexpected combination) than the macro's quote_call match supports — the match on args.len() has no arm for this count, so macro expansion aborts.

Source

Thrown at pyo3-polars/pyo3-polars-derive/src/lib.rs:130

        })
        .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}"),
        },
        _ => panic!("didn't expect so many arguments"),
    };

    let quote_process_result = quote_process_results();
    let fn_name = get_expression_function_name(fn_name);

    quote!(
        use ::pyo3_polars::export::*;

        // create the outer public function
        #[no_mangle]
        pub unsafe extern "C" fn #fn_name (
            e: *mut polars_ffi::version_0::SeriesExport,
            input_len: usize,
            kwargs_ptr: *const u8,
            kwargs_len: usize,
            return_value: *mut polars_ffi::version_0::SeriesExport,
            context: *mut polars_ffi::version_0::CallerContext
        )  {

View on GitHub (pinned to 9b5d73fd00)

Solutions

  1. Reduce the number of arguments passed to the attribute to the expected count.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at pyo3-polars/pyo3-polars-derive/src/lib.rs:130 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/0c0b6fb4e0e19de1. Report an issue: GitHub.