Why this fires¶
An arithmetic operator (+, -, *, /, etc.) was used on two operand types that have no defined arithmetic relationship — e.g. mixing Decimal with float, or a numeric type with str or bool. Zolo's numeric tower allows same-kind widening (int + float → float, int + BigInt → BigInt) but requires an explicit as cast to cross between the Decimal/BigDecimal family and float, and never mixes numbers with non-numeric types implicitly.
let price: Decimal = 9.99d
let tax: float = 0.07
let total = price + tax
// ^^^^^^^^^^^ error[TE009]: arithmetic operation on incompatible types: decimal and floatFix it¶
1. Cast explicitly¶
let total = price + (tax as Decimal) // ok2. Use matching types from the start¶
let price: Decimal = 9.99d
let tax: Decimal = 0.07d
let total = price + tax // ok — both DecimalSee also¶
- /docs/variables-and-types — the numeric tower (
int,float,BigInt,Decimal,BigDecimal) and widening rules.