{"record":{"id":"043c788593b4193c","repo":"BoundaryML/baml","slug":"a-call-s-type-argument-count-fits-in-u16","errorCode":null,"errorMessage":"a call's type-argument count fits in u16","messagePattern":"a call's type-argument count fits in u16","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_compiler2_emit/src/emit.rs","lineNumber":2405,"sourceCode":"\n            Terminator::Return => {\n                // Use pull model for return value - if _0 is Virtual, inline it\n                unwrap_infallible(pull_semantics::walk_return_value(self));\n                self.emit(Instruction::Return);\n            }\n\n            Terminator::Call {\n                argument_layout,\n                callee,\n                args,\n                ntypeargs,\n                runtime_id,\n                destination,\n                target,\n                unwind: _,\n            } => {\n                let ntypeargs = u16::try_from(*ntypeargs)\n                    .unwrap_or_else(|_| unreachable!(\"a call's type-argument count fits in u16\"));\n                let call_span = self.current_debug_span;\n                let callee_item = pull_semantics::resolve_constant_function_item(\n                    callee,\n                    &self.analysis.classifications,\n                    &self.analysis.def_use,\n                );\n                let global_callee = callee_item\n                    .as_ref()\n                    .and_then(|item| self.try_function_global_index(item))\n                    .map(GlobalIndex::from_raw);\n\n                if let Some(global_callee) = global_callee {\n                    unwrap_infallible(pull_semantics::walk_call_direct_args(self, args));\n                    if let Some(runtime_id) = runtime_id {\n                        unwrap_infallible(pull_semantics::walk_operand_pull(self, runtime_id));\n                    }\n                    let instruction = if runtime_id.is_some() {\n                        Instruction::CallWithRuntimeId {","sourceCodeStart":2387,"sourceCodeEnd":2423,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_compiler2_emit/src/emit.rs#L2387-L2423","documentation":"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.","triggerScenarios":"Thrown at baml_language/crates/baml_compiler2_emit/src/emit.rs:2405 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}