{"record":{"id":"1ad825c42e934ae4","repo":"swc-project/swc","slug":"finishers-must-return-a-constructor","errorCode":null,"errorMessage":"Finishers must return a constructor.","messagePattern":"Finishers must return a constructor\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_transforms_base/src/helpers/generated/_decorate.rs","lineNumber":266,"sourceCode":"\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\n    return constructor;\n}\n\"#,\n    #[cfg(feature = \"inline-helpers\")]\n    deps: super::HelperBitmap::from_bits(0x0000000601a000044000080000000018),\n};\n\n#[cfg(feature = \"inline-helpers\")]\npub fn stmts() -> &'static [swc_ecma_ast::Stmt] {\n    static STMTS: once_cell::sync::Lazy<Vec<swc_ecma_ast::Stmt>> =\n        once_cell::sync::Lazy::new(|| super::super::parse(DEF.source, DEF.import_path));\n    &STMTS\n}\n","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_transforms_base/src/helpers/generated/_decorate.rs#L248-L284","documentation":"The #[proc_macro_derive(DeserializeEnum, attributes(tag, encoding))] entry point (which backs swc's tag-aware AST deserialization, usually invoked via #[ast_node]) starts by parsing the token stream into syn::DeriveInput with .expect(\"failed to parse input as DeriveInput\"). Because rustc only invokes derives on valid items, this expect is an internal invariant; a panic here means the macro received tokens that do not form a parseable struct/enum/union.","triggerScenarios":"Annotating an item with #[derive(DeserializeEnum)] (or #[ast_node(...)] which forwards to it) where the item's token stream is not a valid DeriveInput - typically macro-generated items that expand to something other than a plain item, or direct token-level invocation of the proc macro.","commonSituations":"Rare in practice: nightly/stable parser drift, derive helper attribute misconfiguration, or procedural-macro test tooling calling derive entry points with raw tokens. If you hit it, the more likely culprits are earlier syntax errors in the same item or an incompatible syn version bundled with a re-exported derive.","solutions":["Fix any syntax errors reported on the same item - rustc normally reports those before invoking derives, but interleaved reporting can surface the panic first.","Expand macros on the item (cargo expand) and verify the result is a well-formed enum definition.","Ensure you are deriving on a direct enum item, not on a macro invocation or module.","Report to swc with a reproducible item if the input is plainly valid."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive DeserializeEnum/ast_node directly on enum definitions, not on macro invocations.","Fix item syntax errors first - a broken item can reach the derive before errors are printed in some nightly builds."],"tags":["rust","proc-macro","derive","deserialize","swc","compile-time"],"backgroundTag":"derive-input-parse-failure","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}