{"record":{"id":"0c00f3a18197f162","repo":"BoundaryML/baml","slug":"interface-body-has-no-pass-1-slot-item","errorCode":null,"errorMessage":"interface body has no Pass-1 slot: {item}","messagePattern":"interface body has no Pass-1 slot: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_compiler2_emit/src/emit.rs","lineNumber":2043,"sourceCode":"    /// Pass-1 global slot for a function item.\n    ///\n    /// An interface-machinery body resolves by its DECLARATION\n    /// ([`baml_compiler2_mir::InterfaceBodyRef::decl`]) through [`Self::interface_body_slots`] —\n    /// its rendered spelling is display-only and keys nothing. Every other\n    /// item resolves by its rendered name through [`Self::globals`]; `None`\n    /// there means the callee is not statically addressable (the caller falls\n    /// back to an indirect call). A body missing its slot is an internal\n    /// error: `ItemRef::InterfaceBody` only exists for declarations this database\n    /// sees, and Pass 1 slots every one of them.\n    fn try_function_global_index(\n        &mut self,\n        item: &baml_compiler2_mir::ItemRef<'ctx>,\n    ) -> Option<usize> {\n        if let baml_compiler2_mir::ItemRef::InterfaceBody(body) = item {\n            let slot = *self\n                .interface_body_slots\n                .get(&body.decl)\n                .unwrap_or_else(|| panic!(\"interface body has no Pass-1 slot: {item}\"));\n            // The body's rendered spelling is display-only for resolution, but\n            // its last segment (the method name) is exactly what the declaring\n            // file's `defined_names` produces — the incremental edge grain.\n            self.references.record(&item.to_string());\n            return Some(slot);\n        }\n        let rendered = item.to_string();\n        let slot = self.globals.get(&rendered).copied();\n        if slot.is_some() {\n            self.references.record(&rendered);\n        }\n        slot\n    }\n\n    /// [`Self::try_function_global_index`], panicking with `what` when the\n    /// item does not resolve.\n    fn function_global_index(\n        &mut self,","sourceCodeStart":2025,"sourceCodeEnd":2061,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_compiler2_emit/src/emit.rs#L2025-L2061","documentation":"During the emit pass, an interface-machinery body (`ItemRef::InterfaceBody`) must already have a global slot assigned in Pass 1, recorded in `interface_body_slots` keyed by the body's declaration. This panic means the slot map has no entry for that declaration. Per the code comments, Pass 1 is supposed to slot every interface body declaration the compiler database sees, so a miss is an internal invariant violation, not user error.","triggerScenarios":"Emitting code that references an interface method body when `interface_body_slots` was populated in Pass 1 without that declaration — e.g. the declaration was added after Pass 1 ran (incremental recompile that added a new interface method), a cross-package/cross-file interface whose body was never slotted, or a stale compiler database after an edit.","commonSituations":"Incremental compilation after editing an interface to add methods; compiler caching keyed incorrectly so a fresh declaration skipped Pass 1; parallel emit workers seeing a declaration set that differs from the Pass-1 serial run.","solutions":["Run a clean (non-incremental) compile to confirm it is a stale-incremental-state issue, then clear the incremental cache","Check that the interface declaration was present when Pass 1 assigned `interface_body_slots`; compare the Pass-1 declaration set against the emitting set","If you just added a method to an interface, rebuild the whole package rather than relying on incremental output","Report a compiler bug with the BAML source and the item text from the panic message"],"exampleFix":"// before (opaque panic on stale incremental state)\n$ baml build\n// after (force full rebuild)\n$ baml clean && baml build","handlingStrategy":"validation","validationCode":"// before compiling, assert every InterfaceBody declaration has a Pass-1 slot\nfor item in all_items {\n    if let ItemRef::InterfaceBody(body) = item {\n        assert!(interface_body_slots.contains_key(&body.decl), \"unslotted interface body: {item}\");\n    }\n}","typeGuard":null,"tryCatchPattern":"// run compilation in a worker and surface panics as diagnostics\nmatch std::panic::catch_unwind(|| compile(inputs)) {\n    Ok(out) => out,\n    Err(_) => diagnose_and_rebuild_from_scratch(),\n}","preventionTips":["Clear incremental caches whenever interface definitions change","Prefer full rebuilds when adding methods to interfaces","Keep Pass 1 and emit consuming the same declaration snapshot","File a bug with repro source if a clean rebuild still panics"],"tags":["compiler","internal-invariant","incremental-compilation","emit"],"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-14T05:17:10.506Z"}