oven-sh/bun · error

Unexpected type in source file {}

Error message

Unexpected type in source file {}

What it means

Error "Unexpected type in source file {}" thrown in oven-sh/bun.

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)

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.