Skip to content
Playground(another site)

bynk.types.no_numeric_coercion

Error Int, Float and Decimal were mixed without an explicit conversion — in an operation, a comparison or refinement bounds.

Int, Float and Decimal are never mixed implicitly, in an operator, a comparison or an InRange bound. Each conversion can lose or invent precision, so Bynk makes you write it: .toFloat() on an Int, .round(), .floor(), .ceil() or .truncate() on a Float, Decimal.fromInt(n) or a decimal literal for a Decimal. The same code covers a Duration or Instant used with an operand it does not support.

Example

fn total(count: Int, price: Float) -> Float {
count * price // ✗ `Int` and `Float` in one operator
}
fn total(count: Int, price: Float) -> Float {
count.toFloat() * price // ✓ explicit conversion
}

In the Book

See also