swc-project/swc · error
internal error: entered unreachable code
Error message
internal error: entered unreachable code
What it means
A `#[cfg(swc_ast_unknown)]` wildcard panic in fold_module_item of the bundler's computed-key pass (computed_key.rs:249). In builds with the swc_ast_unknown feature, AST enums gain an extra unknown variant; when the match on ModuleItem falls through to it (an item the pass does not recognize, injected by an external or newer AST producer), the pass declares the code path unreachable for known nodes and panics.
Source
Thrown at crates/swc_bundler/src/bundler/chunk/computed_key.rs:249
let decl = match item {
ModuleItem::ModuleDecl(decl) => decl,
ModuleItem::Stmt(_) => return item,
#[cfg(swc_ast_unknown)]
_ => panic!("unable to access unknown nodes"),
};
let stmt = match decl {
ModuleDecl::Import(_) => return decl.into(),
ModuleDecl::ExportDecl(export) => {
match &export.decl {
Decl::Class(ClassDecl { ident, .. }) | Decl::Fn(FnDecl { ident, .. }) => {
self.export_id(ident.clone());
}
Decl::Var(decl) => {
let ids: Vec<Ident> = find_pat_ids(decl);
ids.into_iter().for_each(|id| self.export_id(id));
}
_ => unreachable!(),
}
Some(ModuleItem::from(export.decl))
}
ModuleDecl::ExportDefaultDecl(export) => match export.decl {
DefaultDecl::Class(expr) => {
let ident = expr.ident;
let ident = ident.unwrap_or_else(|| private_ident!("_default_decl"));
self.export_key_value(
Ident::new_no_ctxt(atom!("default"), export.span),
ident.clone(),
);
Some(
ClassDecl {
ident,View on GitHub (pinned to 5176682b65)
Solutions
- Ensure the module AST passed to the bundler comes from a compatible swc parser version so no unknown variants appear
- Handle the wildcard variant by passing the item through unchanged instead of panicking
- Rebuild the AST without the swc_ast_unknown feature enabled before bundling
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/swc_bundler/src/bundler/chunk/computed_key.rs:249 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/061b128080d97442.
Report an issue: GitHub.