BoundaryML/baml · error
a call's type-argument count fits in u16
Error message
a call's type-argument count fits in u16
What it means
Internal compiler invariant when emitting a call terminator: the number of type arguments on the call site exceeded u16::MAX (65535). The bytecode Call instruction encodes ntypeargs in 16 bits, so an AST/THIR that produced more type arguments than the encoding allows trips this guard. Realistically only reachable via machine-generated or pathologically generic BAML code; it is a compile-time hard stop, not a runtime failure.
Source
Thrown at baml_language/crates/baml_compiler2_emit/src/emit.rs:2405
Terminator::Return => {
// Use pull model for return value - if _0 is Virtual, inline it
unwrap_infallible(pull_semantics::walk_return_value(self));
self.emit(Instruction::Return);
}
Terminator::Call {
argument_layout,
callee,
args,
ntypeargs,
runtime_id,
destination,
target,
unwind: _,
} => {
let ntypeargs = u16::try_from(*ntypeargs)
.unwrap_or_else(|_| unreachable!("a call's type-argument count fits in u16"));
let call_span = self.current_debug_span;
let callee_item = pull_semantics::resolve_constant_function_item(
callee,
&self.analysis.classifications,
&self.analysis.def_use,
);
let global_callee = callee_item
.as_ref()
.and_then(|item| self.try_function_global_index(item))
.map(GlobalIndex::from_raw);
if let Some(global_callee) = global_callee {
unwrap_infallible(pull_semantics::walk_call_direct_args(self, args));
if let Some(runtime_id) = runtime_id {
unwrap_infallible(pull_semantics::walk_operand_pull(self, runtime_id));
}
let instruction = if runtime_id.is_some() {
Instruction::CallWithRuntimeId {View on GitHub (pinned to bd85ce9dee)
Solutions
- Reduce the number of explicit type arguments at the call site — anything near 65535 arguments is almost certainly generated code or an accidental repetition
- If the call genuinely needs that many type args, restructure with intermediate type aliases or split the call
- Report it to the BAML maintainers if a modest, hand-written program triggers it
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at baml_language/crates/baml_compiler2_emit/src/emit.rs:2405 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/043c788593b4193c.
Report an issue: GitHub.