{"record":{"id":"9c533b0ed5d6549e","repo":"swc-project/swc","slug":"failed-to-swcify-arguments","errorCode":null,"errorMessage":"failed to swcify arguments","messagePattern":"failed to swcify arguments","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_estree_compat/src/swcify/expr.rs","lineNumber":257,"sourceCode":"                Expression::Import(s) => Callee::Import(s.swcify(ctx)),\n                _ => Callee::Expr(e.swcify(ctx)),\n            },\n        }\n    }\n}\n\nimpl Swcify for CallExpression {\n    type Output = CallExpr;\n\n    fn swcify(self, ctx: &Context) -> Self::Output {\n        CallExpr {\n            span: ctx.span(&self.base),\n            callee: self.callee.swcify(ctx),\n            args: self\n                .arguments\n                .swcify(ctx)\n                .into_iter()\n                .map(|v| v.expect(\"failed to swcify arguments\"))\n                .collect(),\n            type_args: self.type_parameters.swcify(ctx).map(Box::new),\n            ..Default::default()\n        }\n    }\n}\n\nimpl Swcify for Arg {\n    type Output = Option<ExprOrSpread>;\n\n    fn swcify(self, ctx: &Context) -> Self::Output {\n        Some(match self {\n            Arg::Spread(s) => ExprOrSpread {\n                spread: Some(ctx.span(&s.base)),\n                expr: s.argument.swcify(ctx),\n            },\n            Arg::JSXName(e) => ExprOrSpread {\n                spread: None,","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_estree_compat/src/swcify/expr.rs#L239-L275","documentation":"`swc_estree_compat` converts Babel (ESTree) ASTs into swc ASTs via the `Swcify` trait. For `CallExpression`, each Babel `Arg` maps to `Option<ExprOrSpread>`; the impl (crates/swc_estree_compat/src/swcify/expr.rs:265) returns `None` for `Arg::Placeholder` and wraps every arg with `expect(\"failed to swcify arguments\")`. So the panic fires when a call expression's argument list contains a Babel Placeholder node, which has no swc equivalent.","triggerScenarios":"Calling `ast.swcify(&ctx)` on a Babel AST parsed with the `placeholders` feature (syntax like `foo(%%x%%)`), so call arguments carry `Arg::Placeholder` nodes. Any other argument kind (Expr, Spread, JSXName) converts fine.","commonSituations":"Consuming Babel fixture ASTs or parser output that enables placeholder syntax (used by Babel's own tests for template holes); deserializing Babel JSON containing `\"Placeholder\"` argument nodes and converting it to swc.","solutions":["Do not enable the Babel parser's placeholder option (or strip `%%...%%` placeholders) before converting the AST.","Pre-process the Babel AST: replace Placeholder args with real expressions or remove them, then call swcify.","If you truly need templated call sites, keep the tree on the Babel side; swc's AST has no placeholder node for arguments."],"exampleFix":"// before\nlet parser = Parser::new(...).with_placeholder_plugin(); // enables %%x%% args\nlet swc_ast = babel_call_expr.swcify(&ctx); // Arg::Placeholder -> panic\n\n// after\n// parse without the placeholder plugin, or replace placeholder args first\nlet swc_ast = babel_call_expr.swcify(&ctx);","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Reject Babel CallExpressions containing Placeholder args before swcify.\nfn call_args_convertible(call: &swc_estree_compat::babel_ast::CallExpression) -> bool {\n    call.arguments.iter().all(|arg| {\n        !matches!(\n            arg,\n            swc_estree_compat::babel_ast::Arg::Placeholder(_)\n        )\n    })\n}","tryCatchPattern":null,"preventionTips":["Do not enable Babel's placeholder syntax when producing ASTs destined for swcify.","Sanitize third-party Babel JSON: scan arguments arrays for type Placeholder and reject or transform them first.","Add a guard pass over the tree before conversion so failures are actionable errors, not panics."],"tags":["ast-conversion","babel","estree","placeholder","swc"],"backgroundTag":"ast-conversion-unsupported-node","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"}