{"record":{"id":"d6f8a5ba9634b759","repo":"swc-project/swc","slug":"failed-to-parse-input-as-an-item","errorCode":null,"errorMessage":"failed to parse input as an item","messagePattern":"failed to parse input as an item","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_codegen_macros/src/lib.rs","lineNumber":39,"sourceCode":"///             ParamOrTsParamProp::TsParamProp(n) => emit!(n),\n///         }\n///     }\n/// }\n/// ```\n///\n///\n/// ## `emit!()`.\n///\n/// `emit!()` macro in `#[node_impl]` functions are special.\n///\n/// Those are replaced with `emit_with` and `adjust_span` methods, depending on\n/// the context.\n#[proc_macro_attribute]\npub fn node_impl(\n    _attr: proc_macro::TokenStream,\n    item: proc_macro::TokenStream,\n) -> proc_macro::TokenStream {\n    let item: ItemImpl = syn::parse(item).expect(\"failed to parse input as an item\");\n\n    let mut output = TokenStream::new();\n\n    for i in item.items {\n        match i {\n            ImplItem::Fn(i) => {\n                let item = expand_node_impl_method(&item.self_ty, i);\n\n                output.extend(item.to_token_stream());\n            }\n\n            _ => {\n                panic!(\"Unexpected item: {i:?}\");\n            }\n        }\n    }\n\n    output.into()","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_codegen_macros/src/lib.rs#L21-L57","documentation":"The #[node_impl] proc-macro in swc_ecma_codegen_macros requires its input to be an impl block; this fires when syn cannot parse the attached item as an ItemImpl — e.g. the attribute is applied to a non-impl item (fn, struct, mod) or the impl block is syntactically malformed, during codegen macro expansion.","triggerScenarios":"Thrown at crates/swc_ecma_codegen_macros/src/lib.rs:39 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Apply #[node_impl] only to `impl` blocks","Ensure the impl block is complete and syntactically valid","If another macro generates the impl, verify the generated tokens form a valid ItemImpl"],"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-14T05:17:10.506Z"}