{"record":{"id":"365145b1c5bad065","repo":"swc-project/swc","slug":"enum-cannot-be-empty","errorCode":null,"errorMessage":"enum cannot be empty","messagePattern":"enum cannot be empty","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ast_node/src/encoding/decode.rs","lineNumber":104,"sourceCode":"                        syn::Fields::Unit => EnumType::Unit,\n                        syn::Fields::Unnamed(_) => {\n                            panic!(\"more than 1 unnamed member field are not allowed\")\n                        }\n                    };\n                    match (*sum.get_or_insert(ty), ty) {\n                        (EnumType::Struct, EnumType::Struct)\n                        | (EnumType::Struct, EnumType::Unit)\n                        | (EnumType::Unit, EnumType::Unit)\n                        | (EnumType::One, EnumType::One) => (),\n                        (EnumType::Unit, EnumType::One)\n                        | (EnumType::One, EnumType::Unit)\n                        | (_, EnumType::Struct) => sum = Some(EnumType::Struct),\n                        _ => panic!(\"enum member types must be consistent: {:?}\", (sum, ty)),\n                    }\n                    sum\n                },\n            );\n            let enum_type = enum_type.expect(\"enum cannot be empty\");\n            let mut iter = data.variants.iter().peekable();\n\n            let unknown_arm: Option<syn::Arm> = iter.next_if(|variant| is_unknown(&variant.attrs))\n                .map(|unknown| {\n                    let name = &unknown.ident;\n                    assert!(\n                        unknown.discriminant.is_none(),\n                        \"unknown member is not allowed custom discriminant\"\n                    );\n                    assert!(\n                        is_with(&unknown.attrs).is_none(),\n                        \"unknown member is not allowed with type\"\n                    );\n\n                    match &unknown.fields {\n                        syn::Fields::Unnamed(fields) => match fields.unnamed.len() {\n                            1 => {\n                                assert_eq!(enum_type, EnumType::Unit);","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/ast_node/src/encoding/decode.rs#L86-L122","documentation":"Compile-time panic in the ast_node encoding derive (decode side): the tagged-encoding expansion found an enum with no usable variants (empty enum), which the derive cannot generate a decoder for. It fires during macro expansion of #[ast_node]/encoding derives, not at runtime.","triggerScenarios":"Thrown at crates/ast_node/src/encoding/decode.rs:104 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add at least one variant to the enum","Exclude the empty enum from the encoding derive"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}