{"record":{"id":"b6442ecb1f5945fa","repo":"denoland/deno","slug":"unnamed-fields-are-currently-not-supported","errorCode":null,"errorMessage":"Unnamed fields are currently not supported","messagePattern":"Unnamed fields are currently not supported","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"libs/ops/webidl/dictionary.rs","lineNumber":33,"sourceCode":"use syn::Token;\nuse syn::Type;\nuse syn::ext::IdentExt;\nuse syn::parse::Parse;\nuse syn::parse::ParseStream;\nuse syn::punctuated::Punctuated;\nuse syn::spanned::Spanned;\n\nuse super::kw;\n\npub fn get_body(\n  ident_string: String,\n  span: Span,\n  data: DataStruct,\n) -> Result<TokenStream, Error> {\n  let fields = match data.fields {\n    Fields::Named(fields) => fields,\n    Fields::Unnamed(_) => {\n      return Err(Error::new(\n        span,\n        \"Unnamed fields are currently not supported\",\n      ));\n    }\n    Fields::Unit => {\n      return Err(Error::new(span, \"Unit fields are currently not supported\"));\n    }\n  };\n\n  let mut fields = fields\n    .named\n    .into_iter()\n    .map(TryInto::try_into)\n    .collect::<Result<Vec<DictionaryField>, Error>>()?;\n  fields.sort_by(|a, b| a.name.cmp(&b.name));\n\n  let names = fields\n    .iter()","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/libs/ops/webidl/dictionary.rs#L15-L51","documentation":"The `#[webidl(dictionary)]` converter generator (libs/ops/webidl/dictionary.rs) only handles structs with named fields, because a WebIDL dictionary is by definition a set of named members. `get_body` matches on `DataStruct::fields` and rejects tuple structs with this error on the struct's span.","triggerScenarios":"`#[derive(WebIDL)] #[webidl(dictionary)] struct Point(String, f64);` — any tuple struct passed to the webidl dictionary derive.","commonSituations":"Reusing an existing tuple struct (a newtype wrapper like `struct Handle(u32)`) as a webidl dictionary; refactoring named fields into positional ones.","solutions":["Convert the struct to named fields: `struct Point { x: f64, y: f64 }` — each field becomes a dictionary member with a camelCased JS name.","For newtype wrappers, implement the conversion manually or map the inner value to a named field."],"exampleFix":"// before\n#[derive(WebIDL)]\n#[webidl(dictionary)]\nstruct Point(f64, f64);\n\n// after\n#[derive(WebIDL)]\n#[webidl(dictionary)]\nstruct Point { pub x: f64, pub y: f64 }","handlingStrategy":"validation","validationCode":"// Compile-time: `cargo check`. Rule of thumb: webidl dictionary == struct with\n// named fields only. Reject tuple structs before adding the derive.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never feed tuple structs (including newtypes) to `#[webidl(dictionary)]`.","Convert newtype wrappers to a single named field if they must cross the boundary."],"tags":["webidl","proc-macro","derive-macro","tuple-struct","compile-time"],"backgroundTag":"unsupported-struct-shape","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}