{"record":{"id":"12aa253e40529fe1","repo":"BoundaryML/baml","slug":"unsupported-types-for-operator-at-12aa25","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":2396,"sourceCode":"            (BamlValueWithMeta::Float(a, _), BamlValueWithMeta::Int(b, _)) => {\n                BamlValueWithMeta::Float(a - (b as f64), meta.clone())\n            }\n            _ => bail!(\"unsupported types for - operator at {:?}\", meta.0),\n        },\n        BinaryOperator::Mul => match (left_val.clone(), right_val.clone()) {\n            (BamlValueWithMeta::Int(a, _), BamlValueWithMeta::Int(b, _)) => {\n                BamlValueWithMeta::Int(a * b, meta.clone())\n            }\n            (BamlValueWithMeta::Float(a, _), BamlValueWithMeta::Float(b, _)) => {\n                BamlValueWithMeta::Float(a * b, meta.clone())\n            }\n            (BamlValueWithMeta::Int(a, _), BamlValueWithMeta::Float(b, _)) => {\n                BamlValueWithMeta::Float((a as f64) * b, meta.clone())\n            }\n            (BamlValueWithMeta::Float(a, _), BamlValueWithMeta::Int(b, _)) => {\n                BamlValueWithMeta::Float(a * (b as f64), meta.clone())\n            }\n            _ => bail!(\"unsupported types for * operator at {:?}\", meta.0),\n        },\n        BinaryOperator::Div => match (left_val.clone(), right_val.clone()) {\n            (BamlValueWithMeta::Int(a, _), BamlValueWithMeta::Int(b, _)) => {\n                if b == 0 {\n                    bail!(\"division by zero at {:?}\", meta.0);\n                }\n                BamlValueWithMeta::Float((a as f64) / (b as f64), meta.clone())\n            }\n            (BamlValueWithMeta::Float(a, _), BamlValueWithMeta::Float(b, _)) => {\n                if b == 0.0 {\n                    bail!(\"division by zero at {:?}\", meta.0);\n                }\n                BamlValueWithMeta::Float(a / b, meta.clone())\n            }\n            (BamlValueWithMeta::Int(a, _), BamlValueWithMeta::Float(b, _)) => {\n                if b == 0.0 {\n                    bail!(\"division by zero at {:?}\", meta.0);\n                }","sourceCodeStart":2378,"sourceCodeEnd":2414,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-compiler/src/thir/interpret.rs#L2378-L2414","documentation":"THIR interpreter runtime error: the binary `*` operator was applied to operand types with no defined multiplication. Only int/int, float/float, and mixed numeric pairs are supported; other combinations fall through to this bail, tagged with the expression location metadata.","triggerScenarios":"Multiplying strings (e.g. JS-style repeat), nulls, booleans, or lists; a value from LLM output or config that is a string used in multiplication.","commonSituations":"Attempting `\"ab\" * 3` repetition which is unsupported; null from a failed expression; numeric strings from parsed output used directly in arithmetic.","solutions":["Ensure both operands are Int or Float; convert explicitly if needed","Parse numeric strings before multiplying","Handle null/missing values before the operation","For string repetition, use a loop or explicit helper instead of `*`"],"exampleFix":"// before\nlet total = price * \"3\";\n// after\nlet total = price * toInt(\"3\");","handlingStrategy":"validation","validationCode":"if (typeof a !== 'number' || typeof b !== 'number') { throw new Error('multiplication requires numeric operands'); }","typeGuard":"function isNumeric(v) { return typeof v === 'number' && !Number.isNaN(v); }","tryCatchPattern":"try { result = a * b; } catch (e) { if (String(e).includes('unsupported types for *')) { /* convert to numbers and retry */ } else { throw e; } }","preventionTips":["Avoid string-repetition idioms from other languages","Convert operands to numbers explicitly","Validate LLM/config-sourced values before arithmetic"],"tags":["runtime","operators","type-error","interpreter"],"backgroundTag":"unsupported-operation","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"}