oven-sh/bun · error
Unexpected type in source file
Error message
Unexpected type in source file {} What it means
Internal exhaustiveness guard in convertStmtsForChunk: while rewriting cross-chunk statements the linker encountered a Stmt variant it did not expect in that position. It indicates an internal invariant violation or an unhandled AST shape, with the debug name interpolated.
Solutions
- Minimize the input file producing the unexpected statement type and report it as a Bun bundler bug
- Try disabling the transforms in play (e.g. ESM-to-CJS interop, minify) to work around it
- Retry after updating Bun — new statement kinds are added over time
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/bundler/linker_context/convertStmtsForChunk.rs:553 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/8074b89bb443eb2a.
Report an issue: GitHub.
Appendix: source
Thrown at src/bundler/linker_context/convertStmtsForChunk.rs:553
// "export default class {}" => "class default {}"
// "export default class foo {}" => "class foo {}"
// Be careful to not modify the original statement
stmt = Stmt::alloc(
S::Class {
// SAFETY: shallow bitwise copy of arena-backed E::Class.
class: unsafe {
core::ptr::read(&raw const s2.class)
},
is_export: false,
},
stmt.loc,
);
stmt.data.s_class_mut().unwrap().class.class_name =
Some(s.default_name);
}
_ => unreachable!(
"Unexpected type in source file {}",
bstr::BStr::new(
&c.parse_graph()
.input_files
.get(
c.graph
.files
.get(source_index as usize)
.input_file
.get()
as usize
)
.source
.path
.text
),
),
}View on GitHub (pinned to 8c5296ac45)