{"record":{"id":"464b5cd52a3fd660","repo":"BoundaryML/baml","slug":"baml-panics-unreachable","errorCode":"baml.panics.Unreachable","errorMessage":"unreachable code executed","messagePattern":"unreachable code executed","errorType":"error_code","errorClass":"VmPanic","httpStatus":null,"severity":"critical","filePath":"baml_language/crates/bex_vm_types/src/errors.rs","lineNumber":54,"sourceCode":"    #[error(\"index out of bounds: {index} of {length}\")]\n    IndexOutOfBounds { index: i64, length: usize },\n\n    #[error(\"invalid field access: field {field_index} of {field_count}\")]\n    InvalidFieldAccess {\n        field_index: usize,\n        field_count: usize,\n    },\n\n    #[error(\"key not found in map\")]\n    MapKeyNotFound,\n\n    #[error(\"stack overflow\")]\n    StackOverflow,\n\n    #[error(\"assertion failed\")]\n    AssertionFailed,\n\n    #[error(\"unreachable code executed\")]\n    Unreachable,\n\n    #[error(\"operation cancelled\")]\n    Cancelled,\n\n    /// A user-caused panic from `baml.sys.panic`, and the stdlib's panic of\n    /// record for a user-violated native invariant (e.g. a reflection kind\n    /// view's `_ty` field overwritten with a type of a different kind).\n    #[error(\"baml.sys.panic: {message}\")]\n    UserPanic { message: String },\n\n    /// A clean process-termination request from `baml.sys.exit(code)`.\n    ///\n    /// Catchable in user code as `baml.panics.Exit` — patterned after\n    /// Python's `SystemExit`: code can intercept it for cleanup or\n    /// testing, and if nothing catches it the engine surfaces the code\n    /// as `EngineError::Exit` and the host terminates with it.\n    ///","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_vm_types/src/errors.rs#L36-L72","documentation":"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.","triggerScenarios":"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.","commonSituations":"Compiler bugs with exhaustiveness checking, hand-edited or stale bytecode, running an old compiled artifact against a newer VM (or vice versa).","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// BAML: top-level guard while investigating\ntry {\n  run(program);\n} catch (e: baml.panics.Unreachable) {\n  report_compiler_bug(e);\n}","preventionTips":["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"],"tags":["vm","unreachable","compiler","panic","baml"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}