BoundaryML/baml · critical · VmPanic
baml.panics.Unreachable
baml.panics.Unreachable
Error message
unreachable code executed
What it means
Raised when the VM executes an `unreachable` instruction, meaning a code path the compiler proved (or assumed) impossible was actually reached. This signals a compiler/assumption bug or corrupted/patched bytecode rather than normal user error.
Solutions
- Report it as a likely compiler bug with the program that triggered it.
- Recompile the program with the current compiler to regenerate bytecode.
- Catch `baml.panics.Unreachable` at a top-level boundary to avoid a hard crash while investigating.
Defensive patterns
Strategy: try-catch
Try / catch
// BAML: top-level guard while investigating
try {
run(program);
} catch (e: baml.panics.Unreachable) {
report_compiler_bug(e);
} Prevention
- Always regenerate bytecode with the same compiler version as the VM
- Never hand-edit or patch compiled artifacts
- Report reachable-unreachable cases as compiler bugs
When it happens
Trigger: Executing compiled `unreachable` markers, e.g. after an exhaustive match the compiler considered total but that received an unexpected value, or running bytecode from an incompatible compiler version.
Common situations: Compiler bugs with exhaustiveness checking, hand-edited or stale bytecode, running an old compiled artifact against a newer VM (or vice versa).
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- ======================================== BAML Internal…
- baml.panics.AssertionFailed
- baml.panics.Cancelled
- baml.panics.Exit
- baml.panics.IndexOutOfBounds
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/464b5cd52a3fd660.
Report an issue: GitHub.
Appendix: source
Thrown at baml_language/crates/bex_vm_types/src/errors.rs:54
#[error("index out of bounds: {index} of {length}")]
IndexOutOfBounds { index: i64, length: usize },
#[error("invalid field access: field {field_index} of {field_count}")]
InvalidFieldAccess {
field_index: usize,
field_count: usize,
},
#[error("key not found in map")]
MapKeyNotFound,
#[error("stack overflow")]
StackOverflow,
#[error("assertion failed")]
AssertionFailed,
#[error("unreachable code executed")]
Unreachable,
#[error("operation cancelled")]
Cancelled,
/// A user-caused panic from `baml.sys.panic`, and the stdlib's panic of
/// record for a user-violated native invariant (e.g. a reflection kind
/// view's `_ty` field overwritten with a type of a different kind).
#[error("baml.sys.panic: {message}")]
UserPanic { message: String },
/// A clean process-termination request from `baml.sys.exit(code)`.
///
/// Catchable in user code as `baml.panics.Exit` — patterned after
/// Python's `SystemExit`: code can intercept it for cleanup or
/// testing, and if nothing catches it the engine surfaces the code
/// as `EngineError::Exit` and the host terminates with it.
///View on GitHub (pinned to bd85ce9dee)