denoland/deno · error · syn::Error
unknown webidl argument, expected `default` or `options`
Error message
unknown webidl argument, expected `default` or `options`
What it means
`WebIDLArgs::parse` accepts exactly two keys inside `webidl(...)`: `default` and `options`. Any other identifier key raises this error on that key's span, listing the two valid alternatives.
Source
Thrown at libs/ops/op2/signature.rs:321
"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![,]>()?;
}
}
Ok(WebIDLArgs { default, options })
}
}
/// Args are not a 1:1 mapping with Rust types, rather they represent broad classes of types that
/// tend to have similar argument handling characteristics. This may need one more level of indirection
/// given how many of these types have option variants, however.
#[derive(Clone, Debug, Eq, PartialEq)]View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Use only `default = <expr>` (fallback value) and `options(...)` (allowed-value pairs) inside `webidl(...)`.
- For optional parameters, type the parameter as `Option<T>` (the dictionary generator auto-defaults Options to None) instead of inventing an `optional` key.
- Check the spelling — `defaults`/`Default` will not match.
Example fix
// before #[op2(webidl(optional = true))] color: Color, // after #[op2(webidl(default = Color::Red))] color: Color,
Defensive patterns
Strategy: validation
Validate before calling
// Compile-time: `cargo check`. Remember the closed set: // webidl(default = <expr>) and webidl(options(...)) // — there is no `optional`, `required`, or `values` key.
Prevention
- For optional parameters use `Option<T>` in the signature instead of an invented key.
- Double-check key spelling (`default`, `options`) before compiling.
When it happens
Trigger: `#[op2(webidl(value = 3))]` or any `webidl(<key> ...)` where `<key>` is not `default` or `options`, e.g. typos like `defaults`, `optional`, or `values`.
Common situations: Guessing argument names based on general WebIDL knowledge (`optional`, `required`, `values`) instead of the two this macro supports; typos after refactoring.
Related errors
- Only ASCII keys are supported
- duplicate `default` argument
- duplicate `options` argument
- 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/9faa5304b95d3a96.
Report an issue: GitHub.