{"record":{"id":"7485127efb4eed85","repo":"swc-project/swc","slug":"generic-parameter-other-than-type","errorCode":null,"errorMessage":"generic parameter other than type","messagePattern":"generic parameter other than type","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_quote_macros/src/ret_type.rs","lineNumber":91,"sourceCode":"    let mut parser = Parser::new_from(lexer);\n    op(&mut parser)\n        .map_err(|err| anyhow!(\"{err:?}\"))\n        .with_context(|| format!(\"failed to parse input as `{}`\", type_name::<T>()))\n        .map(|val| BoxWrapper(Box::new(val)))\n}\n\nfn extract_generic<'a>(name: &str, ty: &'a Type) -> Option<&'a Type> {\n    if let Type::Path(p) = ty {\n        let last = p.path.segments.last().unwrap();\n\n        if !last.arguments.is_empty() && last.ident == name {\n            match &last.arguments {\n                PathArguments::AngleBracketed(tps) => {\n                    let arg = tps.args.first().unwrap();\n\n                    match arg {\n                        GenericArgument::Type(arg) => return Some(arg),\n                        _ => unimplemented!(\"generic parameter other than type\"),\n                    }\n                }\n                _ => unimplemented!(\"Box() -> T or Box without a type parameter\"),\n            }\n        }\n    }\n\n    None\n}\n","sourceCodeStart":73,"sourceCodeEnd":101,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_quote_macros/src/ret_type.rs#L73-L101","documentation":"The quote!/quote_module! proc-macro helper extract_generic only supports generic arguments that are types; when the named generic (e.g. Box<T>) has an angle-bracketed argument that is a lifetime or const, it aborts. This is a compile-time failure of code using swc_ecma_quote_macros with a non-type generic parameter in its expected return type.","triggerScenarios":"Thrown at crates/swc_ecma_quote_macros/src/ret_type.rs:91 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a plain type parameter, e.g. Box<Expr>, to the quote macro's expected type","Extend extract_generic to handle lifetime/const generic arguments","Restructure the macro invocation so the generic argument is a type"],"exampleFix":null,"handlingStrategy":"type-guard","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-23T08:17:48.524Z"}