{"record":{"id":"c8908ef5027b65bb","repo":"swc-project/swc","slug":"box-t-or-box-without-a-type-parameter","errorCode":null,"errorMessage":"Box() -> T or Box without a type parameter","messagePattern":"Box\\(\\) -> T or Box without a type parameter","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_quote_macros/src/ret_type.rs","lineNumber":94,"sourceCode":"        .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":76,"sourceCodeEnd":101,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_quote_macros/src/ret_type.rs#L76-L101","documentation":"extract_generic requires the named generic (Box) in the quote macro's expected return type to carry exactly one type parameter; a bare `Box` or empty angle brackets provide no argument to extract, so the macro aborts at compile time.","triggerScenarios":"Thrown at crates/swc_ecma_quote_macros/src/ret_type.rs:94 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Write the return type with an explicit type parameter, e.g. Box<Expr>","Return None from extract_generic and emit a friendly compile_error! at the call site","Reject the malformed type earlier in parse_input_type with a clearer message"],"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"}