Skip to content
ZOLO / TE009 Type · error

arithmetic on incompatible types

Binary arithmetic requires both operands to be numeric and (in strict mode) the same numeric type.

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 float

Fix it

1. Cast explicitly

let total = price + (tax as Decimal)   // ok

2. Use matching types from the start

let price: Decimal = 9.99d
let tax: Decimal = 0.07d
let total = price + tax                 // ok — both Decimal

See also

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br