{"record":{"id":"171e08a5c6dff06d","repo":"BoundaryML/baml","slug":"fn-name-expected-float-at-index-index-got","errorCode":null,"errorMessage":"{fn_name}: expected float at index {index}, got {}","messagePattern":"(.+?): expected float at index (.+?), got (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_vm/src/package_baml/root.rs","lineNumber":937,"sourceCode":"    if value.as_bool().is_some() {\n        return \"bool\".to_string();\n    }\n    if value.is_omitted() {\n        return \"omitted\".to_string();\n    }\n    if let Some(ptr) = value.as_object_ptr() {\n        return ObjectType::of(vm.get_object(ptr)).to_string();\n    }\n    \"unknown\".to_string()\n}\n\n/// Extracts a float from a validated `float[]` element. The `FloatStats` /\n/// `Summable` methods are declared on `float[]`, so by the time execution reaches\n/// the native path each element is a boxed float; any other tag is an upstream\n/// invariant violation.\nfn expect_float(vm: &BexVm, value: Value, fn_name: &str, index: usize) -> f64 {\n    let Some(ptr) = value.as_object_ptr() else {\n        unreachable!(\n            \"{fn_name}: expected float at index {index}, got {}\",\n            value_type_name(vm, value)\n        );\n    };\n    match vm.get_object(ptr) {\n        Object::Float(float) => *float,\n        _ => unreachable!(\n            \"{fn_name}: expected float at index {index}, got {}\",\n            value_type_name(vm, value)\n        ),\n    }\n}\n\n/// Extracts an `i64` from a validated `int[]` element. Ints are unboxed tagged\n/// values, so no heap read is needed; a missing int tag is an upstream invariant\n/// violation.\nfn expect_int(value: Value, fn_name: &str, index: usize) -> i64 {\n    value","sourceCodeStart":919,"sourceCodeEnd":955,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_vm/src/package_baml/root.rs#L919-L955","documentation":"Panic in expect_float when a validated float[] element has no object pointer at all (e.g. an unboxed or null-tagged value). FloatStats/Summable methods are declared on float[] and elements should already be boxed Float objects; any other tag is an upstream invariant violation.","triggerScenarios":"Invoking sum or median on a float[] where an element is not a heap-allocated Float object (missing object pointer) — e.g. array contents corrupted or mis-typed upstream.","commonSituations":"Calling float-array statistics methods on arrays built through unchecked paths, aliasing bugs, or VM type-checker gaps.","solutions":["Rebuild the array with explicit float elements before calling sum/median.","Check that the value bound to the float[] is genuinely a float[] and not a subtype/mixed array.","Report to maintainers — validated float[] elements must be boxed floats."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// before calling float stats\nif (!arr.every(v => typeof v === 'number')) throw new Error('expected float[] elements');","typeGuard":"const isFloatArray = (a) => Array.isArray(a) && a.every(v => typeof v === 'number');","tryCatchPattern":null,"preventionTips":["Build arrays only through checked float constructors.","Match declared type to actual element types."],"tags":["vm-panic","invariant","float","type-safety"],"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-23T08:17:48.524Z"}