BoundaryML/baml · error
unsupported types for /= operator
Error message
unsupported types for /= operator
What it means
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.
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.
Example fix
// before total /= "2" // after total /= 2
Defensive patterns
Strategy: validation
Validate before calling
if (!isNumber(acc) || !isNumber(rhs)) throw new Error('/= requires numeric operands'); if (rhs === 0) throw new Error('divisor is zero'); Type guard
function isNumber(v) { return typeof v === 'number'; } Try / catch
try { applyAssignOp('DivAssign', lhs, rhs); } catch (e) { if (e.message.includes('unsupported types for /=')) { /* coerce to numbers */ } else { throw e; } } Prevention
- Parse numeric strings before division.
- Keep /= operands strictly int/float.
- Validate the accumulator's type before the operation.
When it happens
Trigger: Executing `x /= y` where x or y is not an Int or Float at runtime.
Common situations: Dividing a variable holding a string numeric literal, or /= on an uninitialized (null) accumulator.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- unsupported types for *= operator
- unsupported types for -= operator
- unsupported types for += operator
- division by zero at
- division by zero in /= operator
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/ee0c9bc39260f360.
Report an issue: GitHub.
Appendix: source
Thrown at engine/baml-compiler/src/thir/interpret.rs:955
(
BamlValueWithMeta::Int(a, meta),
BamlValueWithMeta::Float(b, _),
) => {
if b == 0.0 {
bail!("division by zero in /= operator");
}
BamlValueWithMeta::Float((a as f64) / b, meta)
}
(
BamlValueWithMeta::Float(a, meta),
BamlValueWithMeta::Int(b, _),
) => {
if b == 0 {
bail!("division by zero in /= operator");
}
BamlValueWithMeta::Float(a / (b as f64), meta)
}
_ => bail!("unsupported types for /= operator"),
},
AssignOp::ModAssign => match (current_val.clone(), rhs_val.clone()) {
(BamlValueWithMeta::Int(a, meta), BamlValueWithMeta::Int(b, _)) => {
if b == 0 {
bail!("modulo by zero in %= operator");
}
BamlValueWithMeta::Int(a % b, meta)
}
_ => bail!("unsupported types for %= operator"),
},
AssignOp::BitXorAssign => {
match (current_val.clone(), rhs_val.clone()) {
(
BamlValueWithMeta::Int(a, meta),
BamlValueWithMeta::Int(b, _),
) => BamlValueWithMeta::Int(a ^ b, meta),
_ => bail!("bitwise ^= requires integer operands"),
}View on GitHub (pinned to bd85ce9dee)