swc-project/swc · info
Unknown suffix `{}`
Error message
Unknown suffix `{}` What it means
Internal helper of the `#[parallel]` macro: `node_type` maps the suffix of generated visit methods (`module_items`, `stmts`) to AST types (`ModuleItem`, `Stmt`). The macro's `expand` only ever calls it with those two literals, so `unimplemented!("Unknown suffix ...")` is unreachable from user code and acts as a completeness check for maintainers.
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 d7d7434666)
Solutions
- If extending the macro, add the new suffix mapping in `node_type` and the matching arm in `post_visit_hook`
- No user-side action; if you see this panic on an unmodified swc, report it upstream
Defensive patterns
Strategy: validation
Prevention
- Maintainers: when adding a new method suffix to #[parallel], extend `node_type` and `post_visit_hook` in the same change
- Users seeing this panic on stock swc should report it — it indicates a patched or corrupted macro
When it happens
Trigger: Not triggerable through normal macro usage; fires only if parallel.rs is modified to emit a method with a new suffix without extending `node_type`.
Common situations: Only swc contributors extending the #[parallel] macro itself.
Related errors
- Unknown visitor type: {:?}
- generic parameter other than type
- Box() -> T or Box without a type parameter
- Fast-path injection for Fold / VisitMut where pattern is not
- not implemented
AI-assisted analysis of swc-project/swc@d7d7434666 (2026-08-16).
Data as JSON: /api/errors/767d916ad2b4af8f.
Report an issue: GitHub.