BoundaryML/baml · error

is_type emits bytecode

Error message

is_type emits bytecode

What it means

Internal compiler invariant in narrow-bind emission: PullSink::is_type was expected to return a type blob for the template but instead signaled that it emits bytecode. The narrow-bind path requires a pure type-level answer (it encodes a type template into a constant), so a bytecode-producing sink here means the pull-semantics classification and the emitter disagree. A compiler bug, unreachable from valid user code.

Source

Thrown at baml_language/crates/baml_compiler2_emit/src/emit.rs:2294

            Place::Field { .. } | Place::Index { .. } => {
                unreachable!(
                    "Field/Index stores are handled in emit_statement, not emit_store_place"
                );
            }
        }
    }

    // ========================================================================
    // Terminator Emission
    // ========================================================================

    fn emit_narrow_bind(&mut self, ty_template: &TyTemplate, destination: Local) {
        unwrap_infallible(PullSink::is_type(self, ty_template));
        let last = self
            .bytecode
            .instructions
            .last_mut()
            .expect("is_type emits bytecode");
        if let Instruction::IsType(ty) = *last {
            debug_assert!(!self.captured_locals.contains(&destination));
            *last = Instruction::NarrowBind {
                ty,
                destination: self.local_slots[&destination],
            };
        }
    }

    /// Emit a terminator.
    fn emit_terminator(&mut self, term: &Terminator<'ctx>) {
        match term {
            Terminator::Goto { target } => {
                // Skip jump if target is the next block (fall-through)
                self.emit_jump_unless_fallthrough(*target);
            }

            Terminator::Branch {

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Update baml — the pull-sink classification and emitter are out of sync, which is a compiler bug
  2. Capture the .baml source that triggers it (typically involving a narrow/junction type bind) and report it to the BAML maintainers
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at baml_language/crates/baml_compiler2_emit/src/emit.rs:2294 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/fc3861d3cc77f6ba. Report an issue: GitHub.