{"record":{"id":"b71b5b8bd580a503","repo":"BoundaryML/baml","slug":"a-call-s-argument-count-fits-in-u16","errorCode":null,"errorMessage":"a call's argument count fits in u16","messagePattern":"a call's argument count fits in u16","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_compiler2_emit/src/emit.rs","lineNumber":2497,"sourceCode":"            } => {\n                // Push the method type args then the value args (receiver first),\n                // then the interface type, then the method name — the layout\n                // `OpCode::VirtualCall` expects: it pops the method name, then the\n                // interface, then the `ntypeargs` method type args, then reads the\n                // receiver (first value arg) to resolve the impl at runtime.\n                unwrap_infallible(pull_semantics::walk_call_direct_args(self, args));\n                let iface_const = self.add_constant(ConstValue::Type(\n                    bex_vm_types::anchor_template(&iface.to_template()),\n                ));\n                let inst = self.emit(Instruction::LoadType(iface_const));\n                self.set_operand(inst, OperandMeta::Const(iface.to_string()));\n                self.emit_constant(&Constant::String(method.clone()));\n                if let Some(runtime_id) = runtime_id {\n                    unwrap_infallible(pull_semantics::walk_operand_pull(self, runtime_id));\n                }\n                let nargs = args.len() - ntypeargs;\n                let nargs = u16::try_from(nargs)\n                    .unwrap_or_else(|_| unreachable!(\"a call's argument count fits in u16\"));\n                let ntypeargs = u16::try_from(*ntypeargs)\n                    .unwrap_or_else(|_| unreachable!(\"a call's type-argument count fits in u16\"));\n                let instruction = if runtime_id.is_some() {\n                    Instruction::VirtualCallWithRuntimeId { nargs, ntypeargs }\n                } else {\n                    Instruction::VirtualCall { nargs, ntypeargs }\n                };\n                let inst = self.emit(instruction);\n                self.record_call_layout(inst, argument_layout.as_ref());\n                self.set_operand(inst, OperandMeta::Callable(method.clone()));\n                self.emit_store_place(destination);\n                self.emit_jump_unless_fallthrough(*target);\n            }\n\n            Terminator::Unreachable => {\n                // Emit an instruction that will panic at runtime if reached.\n                // This should never happen - if it does, there's a bug in the\n                // compiler or type system (e.g., non-exhaustive match incorrectly","sourceCodeStart":2479,"sourceCodeEnd":2515,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_compiler2_emit/src/emit.rs#L2479-L2515","documentation":"Internal compiler invariant when emitting a call: the number of value arguments on the call site exceeded u16::MAX (65535). Call instructions encode the argument count in 16 bits, so an oversized argument list (again almost certainly generated or accidentally expanded code) is rejected at emit time with this guard.","triggerScenarios":"Thrown at baml_language/crates/baml_compiler2_emit/src/emit.rs:2497 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the argument count at the call site — near-65535 arguments indicates generated code or accidental list expansion","Bundle the values into a single list or map argument and unpack inside the function","Report it to the BAML maintainers if a reasonable 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-23T08:17:48.524Z"}