{"record":{"id":"718c28f43131f599","repo":"diesel-rs/diesel","slug":"unexpected-token-after-positional-variadic","errorCode":null,"errorMessage":"unexpected token after positional `#[variadic(..)]`","messagePattern":"unexpected token after positional `#\\[variadic\\(\\.\\.\\)\\]`","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"diesel_derives/src/sql_function.rs","lineNumber":1411,"sourceCode":"                        syn::Error::new(e.span(), format!(\"{e}, the correct format is `#[window]`\"))\n                    })?\n                    .clone(),\n                restrictions: BackendRestriction::None,\n                require_order: None,\n                wrap_macro: None,\n            },\n        }),\n        syn::Meta::List(syn::MetaList {\n            path,\n            delimiter: syn::MacroDelimiter::Paren(_),\n            tokens: _,\n        }) if path.is_ident(\"variadic\") => {\n            let (count, flag) = attr\n                .parse_args_with(|input: syn::parse::ParseStream| {\n                    if input.peek(LitInt){\n                        let count = input.parse::<LitInt>()?;\n                        if !input.is_empty(){\n                            return Err(syn::Error::new(input.span(), \"unexpected token after positional `#[variadic(..)]`\"));\n                        }\n                        Ok((count, LitBool::new(false, Span::call_site())))\n                    }\n                    else {\n                        let key: Ident = input.parse()?;\n                        if key != \"last_arguments\" {\n                            return Err(syn::Error::new(key.span(), \"expect `last_arguments`\"));\n                        }\n                        let _eq: Token![=] = input.parse()?;\n                        let count: LitInt = input.parse()?;\n                        let skip_zero: LitBool = if input.peek(Token![,]) {\n                            let _: Token![,] = input.parse()?;\n                            let key: Ident = input.parse()?;\n                            if key != \"skip_zero_argument_variant\" {\n                                return Err(\n                                    syn::Error::new(\n                                        key.span(), \"expect `skip_zero_argument_variant`\"\n                                    )","sourceCodeStart":1393,"sourceCodeEnd":1429,"githubUrl":"https://github.com/diesel-rs/diesel/blob/6fa6ed01b24b24248ab2a611698d0a7c6a2e9120/diesel_derives/src/sql_function.rs#L1393-L1429","documentation":"The `#[variadic(..)]` attribute accepts either a bare integer literal (`#[variadic(3)]`) or a `last_arguments = N` key-value form. If an integer is parsed and any tokens remain inside the parentheses, `parse_attribute` rejects it because a positional count cannot be followed by more content.","triggerScenarios":"Writing `#[variadic(3, foo)]`, `#[variadic(3 last_arguments = 1)]`, or trailing commas/tokens after a plain count, inside a `#[sql_function]` attribute.","commonSituations":"Mixing the positional and named forms in one attribute; typos leaving stray commas or identifiers after the number.","solutions":["Use only the bare count: `#[variadic(3)]`.","If you need the named form, switch entirely to `#[variadic(last_arguments = 3)]`.","Remove stray commas or extra tokens after the integer."],"exampleFix":"// before\n#[sql_function]\n#[variadic(3, last_arguments = 1)]\nfn concat_ws(sep: VarChar);\n\n// after\n#[sql_function]\n#[variadic(last_arguments = 1)]\nfn concat_ws(sep: VarChar);","handlingStrategy":"validation","validationCode":"// Valid variadic forms:\n// #[variadic(3)]                      -- positional count only\n// #[variadic(last_arguments = 3)]     -- named form\n// Anything after the bare integer is invalid.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never mix the positional and named variadic forms in one attribute.","Remove trailing commas and stray tokens inside #[variadic(..)].","Copy an example from diesel tests when unsure of the syntax."],"tags":["rust","proc-macro","diesel","attributes","syntax"],"backgroundTag":"invalid-argument-format","analyzedSha":"6fa6ed01b24b24248ab2a611698d0a7c6a2e9120","analyzedAt":"2026-09-07T01:50:13.074Z","contentChangedAt":"2026-09-07T01:50:13.074Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}