{"record":{"id":"5e2bc8514732fdea","repo":"swc-project/swc","slug":"invalid-type","errorCode":null,"errorMessage":"Invalid type: {:?}","messagePattern":"Invalid type: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_quote_macros/src/ctxt.rs","lineNumber":110,"sourceCode":"        let ident_str = ident.to_string();\n\n        let pos = match var.ty {\n            Some(syn::Type::Path(syn::TypePath {\n                qself: None,\n                path:\n                    syn::Path {\n                        leading_colon: None,\n                        segments,\n                    },\n            })) => {\n                let segment = segments.first().unwrap();\n                match segment.ident.to_string().as_str() {\n                    \"Ident\" => VarPos::Ident,\n                    \"Expr\" => VarPos::Expr,\n                    \"Pat\" => VarPos::Pat,\n                    \"Str\" => VarPos::Str,\n                    \"AssignTarget\" => VarPos::AssignTarget,\n                    _ => panic!(\"Invalid type: {:?}\", segment.ident),\n                }\n            }\n            None => VarPos::Ident,\n            _ => {\n                panic!(\n                    \"Var type should be one of: Ident, Expr, Pat; got {:?}\",\n                    var.ty\n                )\n            }\n        };\n\n        let var_ident = syn::Ident::new(&format!(\"quote_var_{ident}\"), ident.span());\n\n        let old = init_map.entry(pos).or_default().insert(\n            ident_str.clone(),\n            VarData {\n                pos,\n                is_counting: true,","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_quote_macros/src/ctxt.rs#L92-L128","documentation":"In SWC's quote! macro, interpolated variables are typed by annotation, and only Ident, Expr, Pat, Str, and AssignTarget are accepted single-segment type names. A simple type path with any other name (e.g. `as Stmt`, `as Module`) panics the proc macro at compile time with 'Invalid type: {:?}'.","triggerScenarios":"Writing quote! { x as Stmt; ... } or any interpolation annotated with a bare type name outside the five supported ones while authoring macros that use swc_ecma_quote_macros.","commonSituations":"Contributing to SWC or writing custom codegen with the quote macro, assuming any AST node type name can annotate an interpolation, porting examples that used older macro versions.","solutions":["Change the annotation to one of Ident, Expr, Pat, Str, AssignTarget","For non-expression nodes (statements, declarations), restructure the macro to build them from expressions or use the builder API instead of interpolation","Check the macro docs/tests for the supported list before adding new interpolations"],"exampleFix":"// before\nquote!(stmt_var as Stmt; console.log(stmt_var););\n\n// after\nquote!(expr_var as Expr; console.log(expr_var););","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only annotate quote! interpolations with Ident, Expr, Pat, Str, or AssignTarget","Build non-expression nodes with builder methods instead of interpolating them","Compile the proc-macro crate early in CI so macro input errors surface fast"],"tags":["proc-macro","quote","compile-time","annotation"],"backgroundTag":"invalid-macro-type-annotation","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"}