{"record":{"id":"4a7a2d1c6df1cddd","repo":"swc-project/swc","slug":"objecttype-can-t-have-a-name-property","errorCode":null,"errorMessage":"${objectType} can't have a .${name} property.","messagePattern":"(.+?) can't have a \\.(.+?) property\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_transforms_base/src/helpers/generated/_decorate.rs","lineNumber":252,"sourceCode":"    return obj;\n}\nfunction _toClassDescriptor(obj) {\n    var kind = String(obj.kind);\n    if (kind !== \"class\") {\n        throw new TypeError(\"A class descriptor's .kind property must be \\\"class\\\", but a decorator\" + \" created a class descriptor with .kind \\\"\" + kind + \"\\\"\");\n    }\n    _disallowProperty(obj, \"key\", \"A class descriptor\");\n    _disallowProperty(obj, \"placement\", \"A class descriptor\");\n    _disallowProperty(obj, \"descriptor\", \"A class descriptor\");\n    _disallowProperty(obj, \"initializer\", \"A class descriptor\");\n    _disallowProperty(obj, \"extras\", \"A class descriptor\");\n    var finisher = _optionalCallableProperty(obj, \"finisher\");\n    var elements = _toElementDescriptors(obj.elements);\n\n    return { elements: elements, finisher: finisher };\n}\nfunction _disallowProperty(obj, name, objectType) {\n    if (obj[name] !== undefined) throw new TypeError(objectType + \" can't have a .\" + name + \" property.\");\n}\nfunction _optionalCallableProperty(obj, name) {\n    var value = obj[name];\n    if (value !== undefined && typeof value !== \"function\") {\n        throw new TypeError(\"Expected '\" + name + \"' to be a function\");\n    }\n\n    return value;\n}\nfunction _runClassFinishers(constructor, finishers) {\n    for (var i = 0; i < finishers.length; i++) {\n        var newConstructor = (0, finishers[i])(constructor);\n        if (newConstructor !== undefined) {\n            if (typeof newConstructor !== \"function\") throw new TypeError(\"Finishers must return a constructor.\");\n            constructor = newConstructor;\n        }\n    }\n","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_transforms_base/src/helpers/generated/_decorate.rs#L234-L270","documentation":"The second copy of the tag-parsing logic in crates/ast_node/src/enum_deserialize.rs (the block that builds str_pat/bytes_pat for the deserialization match arms) parses #[tag(..)] contents with syn::parse2::<VariantAttr>().expect(\"failed to parse #[tag] attribute\"). The accepted grammar is a comma-terminated list of literals only, so anything else inside the parentheses panics the #[derive(DeserializeEnum)] / #[ast_node] macro at compile time with this message.","triggerScenarios":"A #[tag] attribute on an enum variant whose inner tokens are not literals separated by commas: #[tag(Something)], #[tag(concat(\"a\"))], #[tag(\"a\"; \"b\")]. Reaching the str_pat/bytes_pat block also requires the variant to have exactly one unnamed field, as asserted just above.","commonSituations":"Defining swc-compatible AST enums with serde-style tag syntax; copy-pasting attribute lists from other proc macros that accept expressions; automated codemods rewriting attribute contents and dropping the quotes.","solutions":["Use string literals for tags: #[tag(\"TagName\")] or #[tag(\"Tag1\", \"Tag2\")] with comma separators.","Do not nest attribute syntax or use expressions/macros inside #[tag(..)].","After fixing syntax, confirm every variant still has at least one tag or you will hit the 'All #[ast_node] enum variants have one or more tag' assert next.","Remember \"*\" as the sole tag is the wildcard arm, which follows a different code path."],"exampleFix":"// before\n#[tag(List)]\nExpr(List),\n\n// after\n#[tag(\"List\")]\nExpr(List),","handlingStrategy":"validation","validationCode":"// Same rule in the str/bytes pattern block: literals, comma-separated.\n// Generator-side guard before emitting variants:\nassert!(\n    tags.iter().all(|t| !t.contains('\"') && !t.is_empty()),\n    \"tags must be plain names; they will be emitted as quoted literals\"\n);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep #[tag] contents to quoted literal lists - no expressions, no nested parens.","Ensure every non-wildcard variant keeps at least one tag to avoid the follow-up assert."],"tags":["rust","proc-macro","derive","attribute","swc","compile-time"],"backgroundTag":"derive-macro-attribute-syntax","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"}