{"record":{"id":"72a71daa1219b8d4","repo":"BoundaryML/baml","slug":"unsupported-types-for-operator-at-72a71d","errorCode":null,"errorMessage":"unsupported types for >= operator at {:?}","messagePattern":"unsupported types for >= operator at (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-compiler/src/thir/interpret.rs","lineNumber":2469,"sourceCode":"        BinaryOperator::LtEq => {\n            let ord_opt = compare_values(&left_val.clone(), &right_val.clone())?;\n            let less_eq = ord_opt\n                .map(|ord| matches!(ord, std::cmp::Ordering::Less | std::cmp::Ordering::Equal))\n                .ok_or_else(|| anyhow!(\"unsupported types for <= operator at {:?}\", meta.0))?;\n            BamlValueWithMeta::Bool(less_eq, meta.clone())\n        }\n        BinaryOperator::Gt => {\n            let ord_opt = compare_values(&left_val.clone(), &right_val.clone())?;\n            let greater = ord_opt\n                .map(|ord| matches!(ord, std::cmp::Ordering::Greater))\n                .ok_or_else(|| anyhow!(\"unsupported types for > operator at {:?}\", meta.0))?;\n            BamlValueWithMeta::Bool(greater, meta.clone())\n        }\n        BinaryOperator::GtEq => {\n            let ord_opt = compare_values(&left_val.clone(), &right_val.clone())?;\n            let greater_eq = ord_opt\n                .map(|ord| matches!(ord, std::cmp::Ordering::Greater | std::cmp::Ordering::Equal))\n                .ok_or_else(|| anyhow!(\"unsupported types for >= operator at {:?}\", meta.0))?;\n            BamlValueWithMeta::Bool(greater_eq, meta.clone())\n        }\n\n        // Logical operations\n        BinaryOperator::And => match left_val.clone() {\n            BamlValueWithMeta::Bool(false, _) => BamlValueWithMeta::Bool(false, meta.clone()),\n            BamlValueWithMeta::Bool(true, _) => match right_val.clone() {\n                BamlValueWithMeta::Bool(b, _) => BamlValueWithMeta::Bool(b, meta.clone()),\n                _ => bail!(\"right operand of && must be bool at {:?}\", meta.0),\n            },\n            _ => bail!(\"left operand of && must be bool at {:?}\", meta.0),\n        },\n        BinaryOperator::Or => match left_val.clone() {\n            BamlValueWithMeta::Bool(true, _) => BamlValueWithMeta::Bool(true, meta.clone()),\n            BamlValueWithMeta::Bool(false, _) => match right_val.clone() {\n                BamlValueWithMeta::Bool(b, _) => BamlValueWithMeta::Bool(b, meta.clone()),\n                _ => bail!(\"right operand of || must be bool at {:?}\", meta.0),\n            },","sourceCodeStart":2451,"sourceCodeEnd":2487,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-compiler/src/thir/interpret.rs#L2451-L2487","documentation":"The `>=` operator depends on compare_values returning Some(ordering); for operand pairs with no defined ordering (mismatched types or non-orderable types like bool/array/map/class) it returns None and this bail fires with the expression's source span. This is a compile-time-interpreted type error in the BAML expression.","triggerScenarios":"Evaluating `a >= b` with incompatible or unordered operands: number vs string, string vs number, bools, arrays, maps, class instances, or comparisons involving null.","commonSituations":"Range checks where the upper bound came from string config or LLM output; comparing a typed numeric field against an untyped map value; forgetting a cast after string parsing; comparing booleans with `>=`.","solutions":["Unify operand types with `as int` / `as float` casts (or compare string-to-string)","Inspect both operands (print values/types) at the failing comparison","Fix the schema/prompt so numeric values arrive as numbers, not strings","Null-check optional values before the comparison"],"exampleFix":"// before (.baml)\nif value >= min_str { ... } // min_str: string\n// after (.baml)\nif value >= min_str as int { ... }","handlingStrategy":"validation","validationCode":"// .baml — cast and null-check before `>=`\nlet min = min_str as int;\nif value >= min { ... }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure both sides of `>=` are the same orderable type","Handle null/optional values before range checks","Keep numeric fields typed numerically from schema through to comparison","Print operand types when interpreter comparison errors appear to spot mismatches fast"],"tags":["baml","interpreter","comparison","type-error"],"backgroundTag":"type-mismatch","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"}