{"record":{"id":"ee0c9bc39260f360","repo":"BoundaryML/baml","slug":"unsupported-types-for-operator-ee0c9b","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":955,"sourceCode":"                                (\n                                    BamlValueWithMeta::Int(a, meta),\n                                    BamlValueWithMeta::Float(b, _),\n                                ) => {\n                                    if b == 0.0 {\n                                        bail!(\"division by zero in /= operator\");\n                                    }\n                                    BamlValueWithMeta::Float((a as f64) / b, meta)\n                                }\n                                (\n                                    BamlValueWithMeta::Float(a, meta),\n                                    BamlValueWithMeta::Int(b, _),\n                                ) => {\n                                    if b == 0 {\n                                        bail!(\"division by zero in /= operator\");\n                                    }\n                                    BamlValueWithMeta::Float(a / (b as f64), meta)\n                                }\n                                _ => bail!(\"unsupported types for /= operator\"),\n                            },\n                            AssignOp::ModAssign => match (current_val.clone(), rhs_val.clone()) {\n                                (BamlValueWithMeta::Int(a, meta), BamlValueWithMeta::Int(b, _)) => {\n                                    if b == 0 {\n                                        bail!(\"modulo by zero in %= operator\");\n                                    }\n                                    BamlValueWithMeta::Int(a % b, meta)\n                                }\n                                _ => bail!(\"unsupported types for %= operator\"),\n                            },\n                            AssignOp::BitXorAssign => {\n                                match (current_val.clone(), rhs_val.clone()) {\n                                    (\n                                        BamlValueWithMeta::Int(a, meta),\n                                        BamlValueWithMeta::Int(b, _),\n                                    ) => BamlValueWithMeta::Int(a ^ b, meta),\n                                    _ => bail!(\"bitwise ^= requires integer operands\"),\n                                }","sourceCodeStart":937,"sourceCodeEnd":973,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-compiler/src/thir/interpret.rs#L937-L973","documentation":"THIR interpreter runtime error: the `/=` compound-assign operator was applied to operand types with no supported combination. Division is defined for int/int, float/float, and mixed numeric pairs; other type combinations fall through to this bail during evaluation.","triggerScenarios":"Executing `x /= y` where x or y is not an Int or Float at runtime.","commonSituations":"Dividing a variable holding a string numeric literal, or /= on an uninitialized (null) accumulator.","solutions":["Ensure both operands are numeric before /= (parse/cast strings).","Verify the target variable holds a number.","Use explicit division with typed values instead of the compound operator."],"exampleFix":"// before\ntotal /= \"2\"\n// after\ntotal /= 2","handlingStrategy":"validation","validationCode":"if (!isNumber(acc) || !isNumber(rhs)) throw new Error('/= requires numeric operands'); if (rhs === 0) throw new Error('divisor is zero');","typeGuard":"function isNumber(v) { return typeof v === 'number'; }","tryCatchPattern":"try { applyAssignOp('DivAssign', lhs, rhs); } catch (e) { if (e.message.includes('unsupported types for /=')) { /* coerce to numbers */ } else { throw e; } }","preventionTips":["Parse numeric strings before division.","Keep /= operands strictly int/float.","Validate the accumulator's type before the operation."],"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"}