denoland/deno · error · syn::Error
duplicate `options` argument
Error message
duplicate `options` argument
What it means
Same parser as above: `WebIDLArgs::parse` permits at most one `options(...)` group per webidl attribute. It raises this error on the span of the second `options` key; options themselves are a comma-terminated list of WebIDLPairs inside a single group.
Source
Thrown at libs/ops/op2/signature.rs:310
fn parse(input: ParseStream) -> syn::Result<Self> {
let mut default: Option<WebIDLDefault> = None;
let mut options: Vec<WebIDLPair> = Vec::new();
while !input.is_empty() {
let key: Ident = input.parse()?;
if key == "default" {
if default.is_some() {
return Err(syn::Error::new(
key.span(),
"duplicate `default` argument",
));
}
input.parse::<Token![=]>()?;
default = Some(WebIDLDefault(input.parse::<syn::Expr>()?));
} else if key == "options" {
if !options.is_empty() {
return Err(syn::Error::new(
key.span(),
"duplicate `options` argument",
));
}
let content;
syn::parenthesized!(content in input);
let parsed_options =
content.parse_terminated(WebIDLPair::parse, Token![,])?;
options = parsed_options.into_iter().collect();
} else {
return Err(syn::Error::new(
key.span(),
"unknown webidl argument, expected `default` or `options`",
));
}
if !input.is_empty() {
input.parse::<Token![,]>()?;View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Merge all pairs into one `options(...)` group: `options(a = "x", b = "y")`.
- Delete the stale group left behind by a copy-paste.
Example fix
// before #[op2(webidl(options(prefix = "-"), options(suffix = "+")))] mode: String, // after #[op2(webidl(options(prefix = "-", suffix = "+")))] mode: String,
Defensive patterns
Strategy: validation
Validate before calling
// Compile-time: `cargo check`. When hand-writing, keep all option pairs inside // a single `options(...)` group: options(a = "x", b = "y").
Prevention
- Never paste a second `options(...)` group; extend the existing one with a comma.
- Treat `webidl(...)` as a set of unique keys: `default` once, `options` once.
When it happens
Trigger: `#[op2(webidl(options(a = "x"), options(b = "y")))]` — two `options(...)` groups in one attribute; or repeating `options(...)` after other arguments like `default`.
Common situations: Extending an options list by pasting a second `options(...)` group instead of adding pairs to the existing one.
Related errors
- duplicate `default` argument
- Only ASCII keys are supported
- unknown webidl argument, expected `default` or `options`
- The flags for this attribute were not sorted alphabetically.
- expected attribute arguments in parentheses: `{}(...)`
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/7b948f2820ec52fc.
Report an issue: GitHub.