{"record":{"id":"530588b83f059d1b","repo":"denoland/deno","slug":"enums-currently-do-not-support-dictionary-converte","errorCode":null,"errorMessage":"Enums currently do not support dictionary converters","messagePattern":"Enums currently do not support dictionary converters","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"libs/ops/webidl/mod.rs","lineNumber":43,"sourceCode":"    .attrs\n    .into_iter()\n    .find_map(|attr| ConverterType::from_attribute(attr).transpose())\n    .ok_or_else(|| {\n      Error::new(span, \"missing top-level #[webidl] attribute\")\n    })??;\n\n  let out = match input.data {\n    Data::Struct(data) => match converter {\n      ConverterType::Dictionary => {\n        create_impl(ident, dictionary::get_body(ident_string, span, data)?)\n      }\n      ConverterType::Enum => {\n        return Err(Error::new(span, \"Structs do not support enum converters\"));\n      }\n    },\n    Data::Enum(data) => match converter {\n      ConverterType::Dictionary => {\n        return Err(Error::new(\n          span,\n          \"Enums currently do not support dictionary converters\",\n        ));\n      }\n      ConverterType::Enum => {\n        let (body, as_str) = r#enum::get_body(ident_string, &ident, data)?;\n        let implementation = create_impl(ident, body);\n\n        quote! {\n          #implementation\n          #as_str\n        }\n      }\n    },\n    Data::Union(_) => return Err(Error::new(span, \"Unions are not supported\")),\n  };\n\n  Ok(out)","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/libs/ops/webidl/mod.rs#L25-L61","documentation":"The mirror case: `webidl(dictionary)` generators only handle structs. An `enum` carrying `#[webidl(dictionary)]` is rejected in libs/ops/webidl/mod.rs with this error on the enum's span, because dictionaries need named struct members to map to WebIDL members.","triggerScenarios":"`#[webidl(dictionary)] enum Color { Red, Green }` — annotating an enum with the dictionary converter.","commonSituations":"Turning a struct into an enum (or generalizing a type) without updating the webidl attribute; copy-paste from a dictionary struct.","solutions":["For enums, use `#[webidl(enum)]` (with unit variants only).","If dictionary semantics are required, convert the item into a struct with named fields."],"exampleFix":"// before\n#[derive(WebIDL)]\n#[webidl(dictionary)]\nenum Color { Red, Green }\n\n// after\n#[derive(WebIDL)]\n#[webidl(enum)]\nenum Color { Red, Green }","handlingStrategy":"validation","validationCode":"// Compile-time: `cargo check`. Pairing rule (mirror of 2016):\n//   enum    -> #[webidl(enum)]\n//   struct  -> #[webidl(dictionary)]","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enums take `#[webidl(enum)]`; if you need dictionary semantics, switch the item to a struct with named fields.","Review refactors that generalize structs into enums for stale attributes."],"tags":["webidl","proc-macro","derive-macro","converter-mismatch","compile-time"],"backgroundTag":"converter-type-mismatch","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}