{"record":{"id":"e61bc9ddf058bcce","repo":"denoland/deno","slug":"unit-fields-are-currently-not-supported-e61bc9","errorCode":null,"errorMessage":"Unit fields are currently not supported","messagePattern":"Unit fields are currently not supported","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"libs/ops/conversion/to_v8/struct.rs","lineNumber":150,"sourceCode":"      } else {\n        let fields = fields\n          .into_iter()\n          .map(|field| {\n            let i = format_ident!(\"__{}\", field.i, span = field.span);\n            convert_or_serde(field.serde, field.span, i)\n          })\n          .collect::<Vec<_>>();\n\n        quote! {\n          let __value = &[#(#fields),*];\n          Ok::<_, ::deno_error::JsErrorBox>(::deno_core::v8::Array::new_with_elements(__scope, __value).into())\n        }\n      };\n\n      Ok(value)\n    }\n    Fields::Unit => {\n      Err(Error::new(span, \"Unit fields are currently not supported\"))\n    }\n  }\n}\n\npub struct StructField {\n  pub name: Ident,\n  serde: bool,\n  skip_if: Option<Path>,\n  ty: Type,\n  pub js_name: Ident,\n}\n\nimpl TryFrom<Field> for StructField {\n  type Error = Error;\n  fn try_from(value: Field) -> Result<Self, Self::Error> {\n    let span = value.span();\n    let crate::conversion::SharedAttribute {\n      mut rename,","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/libs/ops/conversion/to_v8/struct.rs#L132-L168","documentation":"The ToV8 struct body generator matches on the struct's Fields: named fields become a V8 object, unnamed fields become a V8 array, and Fields::Unit is rejected with this compile error. A unit struct has neither an object nor an array shape, so the derive refuses instead of inventing one.","triggerScenarios":"Deriving ToV8 on a unit struct declaration (no fields, no braces), e.g. #[derive(ToV8)] struct Flag;.","commonSituations":"Bulk-adding derives via IDE quick-fixes or a shared derive macro that hits marker types; leftover derives after a struct was emptied out.","solutions":["Delete the derive — the simplest correct fix for a data-less type.","Convert the type to carry a field (struct Flag(bool)) or become a newtype so ToV8 has a value to emit.","Return v8::Global/undefined from a manual impl if JS only needs a placeholder."],"exampleFix":"// before\n#[derive(ToV8)]\nstruct Flag; // error: Unit fields are currently not supported\n\n// after\n#[derive(ToV8)]\nstruct Flag(bool);","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep derives in sync with a struct's fields: emptying a struct means removing its conversion derives.","Prefer newtype structs (struct Flag(bool);) over unit structs for anything JS-visible."],"tags":["proc-macro","derive","to-v8","unit-struct","compile-time","deno-core"],"backgroundTag":"derive-macro-unsupported-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"}