{"record":{"id":"3cda1a8ab93aef9c","repo":"swc-project/swc","slug":"type-of-node-parameter-should-be-reference-but-got","errorCode":null,"errorMessage":"Type of node parameter should be reference but got {}","messagePattern":"Type of node parameter should be reference but got (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_xml_codegen_macros/src/lib.rs","lineNumber":40,"sourceCode":"        format!(\"{}\", i.sig.ident).starts_with(\"emit_\"),\n        \"#[emitter] methods should start with `emit_`\"\n    );\n    let block = {\n        let node_type = {\n            i.sig\n                .inputs\n                .clone()\n                .into_iter()\n                .nth(1)\n                .and_then(|arg| match arg {\n                    FnArg::Typed(ty) => Some(ty.ty),\n                    _ => None,\n                })\n                .map(|ty| {\n                    // &Ident -> Ident\n                    match *ty {\n                        Type::Reference(TypeReference { elem, .. }) => *elem,\n                        _ => panic!(\n                            \"Type of node parameter should be reference but got {}\",\n                            ty.into_token_stream()\n                        ),\n                    }\n                })\n                .expect(\n                    \"#[emitter] methods should have signature of\nfn (&mut self, node: Node) -> Result;\n    \",\n                )\n        };\n\n        let block = &i.block;\n        parse_quote!({\n            impl<W> crate::Emit<#node_type> for crate::CodeGenerator<'_, W>\n                where W: crate::writer::XmlWriter,\n            {\n                fn emit(&mut self, n: &#node_type) -> crate::Result {","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_xml_codegen_macros/src/lib.rs#L22-L58","documentation":"A compile-time macro validation panic in `expand` of swc_xml_codegen_macros (lib.rs:40). The #[emitter] macro requires its annotated method's second parameter (the node) to be a reference type; the macro strips the `&` and checks the remaining type. This panic fires when that parameter is not a `Type::Reference`, i.e. the user declared the emit_ method taking the node by value or with some other non-reference type. The offending parameter type in the macro input is the input at fault.","triggerScenarios":"Thrown at crates/swc_xml_codegen_macros/src/lib.rs:40 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Change the #[emitter] method signature so the node parameter is a reference, e.g. `fn emit_ident(&mut self, node: &Ident)`","Add a clearer compile_error! that names the offending method and the expected signature","Document the required parameter shape near the #[emitter] macro definition"],"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"}