{"record":{"id":"06c592e5eb6be120","repo":"BoundaryML/baml","slug":"unsupported-types-for-operator-06c592","errorCode":null,"errorMessage":"unsupported types for *= operator","messagePattern":"unsupported types for \\*= operator","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-compiler/src/thir/interpret.rs","lineNumber":919,"sourceCode":"                                _ => bail!(\"unsupported types for -= operator\"),\n                            },\n                            AssignOp::MulAssign => match (current_val.clone(), rhs_val.clone()) {\n                                (BamlValueWithMeta::Int(a, meta), BamlValueWithMeta::Int(b, _)) => {\n                                    BamlValueWithMeta::Int(a * b, meta)\n                                }\n                                (\n                                    BamlValueWithMeta::Float(a, meta),\n                                    BamlValueWithMeta::Float(b, _),\n                                ) => BamlValueWithMeta::Float(a * b, meta),\n                                (\n                                    BamlValueWithMeta::Int(a, meta),\n                                    BamlValueWithMeta::Float(b, _),\n                                ) => BamlValueWithMeta::Float((a as f64) * b, meta),\n                                (\n                                    BamlValueWithMeta::Float(a, meta),\n                                    BamlValueWithMeta::Int(b, _),\n                                ) => BamlValueWithMeta::Float(a * (b as f64), meta),\n                                _ => bail!(\"unsupported types for *= operator\"),\n                            },\n                            AssignOp::DivAssign => match (current_val.clone(), rhs_val.clone()) {\n                                (BamlValueWithMeta::Int(a, meta), BamlValueWithMeta::Int(b, _)) => {\n                                    if b == 0 {\n                                        bail!(\"division by zero in /= operator\");\n                                    }\n                                    BamlValueWithMeta::Float((a as f64) / (b as f64), meta)\n                                }\n                                (\n                                    BamlValueWithMeta::Float(a, meta),\n                                    BamlValueWithMeta::Float(b, _),\n                                ) => {\n                                    if b == 0.0 {\n                                        bail!(\"division by zero in /= operator\");\n                                    }\n                                    BamlValueWithMeta::Float(a / b, meta)\n                                }\n                                (","sourceCodeStart":901,"sourceCodeEnd":937,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-compiler/src/thir/interpret.rs#L901-L937","documentation":"THIR interpreter runtime error: the `*=` compound-assign operator was applied to operand types with no supported combination. Only int/int and float/float (plus mixed numeric widening) are defined; any other operand types reach this bail while evaluating the assignment.","triggerScenarios":"Executing `x *= y` where x or y is not an Int or Float at runtime.","commonSituations":"Multiplying a count by a string numeric literal, or *= on a variable accidentally holding null/bool.","solutions":["Ensure both operands are numeric (int or float) before *=.","Convert string numerics with explicit parsing/casting.","Verify the accumulator variable is initialized to a number (typically 1 for products)."],"exampleFix":"// before\nproduct *= \"2\"\n// after\nproduct *= 2","handlingStrategy":"validation","validationCode":"if (!isNumber(acc) || !isNumber(rhs)) throw new Error('*= requires numeric operands');","typeGuard":"function isNumber(v) { return typeof v === 'number'; }","tryCatchPattern":"try { applyAssignOp('MulAssign', lhs, rhs); } catch (e) { if (e.message.includes('unsupported types for *=')) { /* coerce to numbers or report */ } else { throw e; } }","preventionTips":["Initialize product accumulators to 1 (numeric).","Parse string numerics before multiplication.","Keep *= operands within int/float types."],"tags":["runtime","type-error","assignment","arithmetic"],"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"}