swc-project/swc · error
Unknown suffix
Error message
Unknown suffix `{}` What it means
Internal panic inside the #[parallel] proc macro's node_type() helper, which maps a method suffix to the AST node type it traverses. Only "module_items" (-> ModuleItem) and "stmts" (-> Stmt) are mapped; the expand() function itself only ever generates those two, so end users cannot trigger this through normal attribute usage.
Solutions
- If extending the macro, add a match arm mapping the new suffix to its node type, e.g. `"exprs" => parse_quote!(Expr)`
- Downstream users hitting this should pin/upgrade to an unmodified release of swc_ecma_transforms_macros
- Check the macro invocation only uses supported entry points (module_items/stmts methods)
Example fix
// before (crates/swc_ecma_transforms_macros/src/parallel.rs)
fn node_type(suffix: &str) -> Type {
match suffix {
"module_items" => parse_quote!(ModuleItem),
"stmts" => parse_quote!(Stmt),
_ => unimplemented!("Unknown suffix `{}`", suffix),
}
}
// after
fn node_type(suffix: &str) -> Type {
match suffix {
"module_items" => parse_quote!(ModuleItem),
"stmts" => parse_quote!(Stmt),
"exprs" => parse_quote!(Expr),
_ => unimplemented!("Unknown suffix `{}`", suffix),
}
} Defensive patterns
Strategy: validation
Prevention
- Downstream users: do not patch or vendor swc_ecma_transforms_macros with new suffixes unless node_type() is extended in the same change
- Maintainers: any new make_par_visit_method suffix must get a node_type arm plus a fixture test
- Treat this panic as an internal invariant violation — report it upstream rather than working around it in user code
When it happens
Trigger: Only reachable by modifying swc_ecma_transforms_macros itself: adding a make_par_visit_method call with a new suffix (e.g. "exprs") without extending node_type()'s match arms.
Common situations: Contributing a new parallel traversal method to the swc macro crate and forgetting to register the suffix-to-type mapping in node_type().
Related errors
- A class descriptor's .kind property must be "class", but a…
- An element descriptor's .kind property must be either…
- An element descriptor's .placement property must be one of…
- #[ast_serde] on enum does not accept any argument
- #[derive(FromVariant)] only works for an enum.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/767d916ad2b4af8f.
Report an issue: GitHub.
Appendix: source
Thrown at crates/swc_ecma_transforms_macros/src/parallel.rs:45
.unwrap_or(false);
item.items.push(ImplItem::Fn(make_par_visit_method(
mode,
"module_items",
explode,
)));
item.items
.push(ImplItem::Fn(make_par_visit_method(mode, "stmts", explode)));
item
}
fn node_type(suffix: &str) -> Type {
match suffix {
"module_items" => parse_quote!(ModuleItem),
"stmts" => parse_quote!(Stmt),
_ => {
unimplemented!("Unknown suffix `{}`", suffix)
}
}
}
fn post_visit_hook(mode: Mode, suffix: &str) -> Option<Expr> {
match suffix {
"module_items" => Some(match mode {
Mode::Fold => parse_quote!(
swc_ecma_transforms_base::perf::Parallel::after_module_items(self, &mut nodes)
),
Mode::VisitMut => parse_quote!(
swc_ecma_transforms_base::perf::Parallel::after_module_items(self, nodes)
),
}),
"stmts" => Some(match mode {
Mode::Fold => parse_quote!(swc_ecma_transforms_base::perf::Parallel::after_stmts(
self, &mut nodesView on GitHub (pinned to 5176682b65)