Skip to content
Playground(another site)

bynk.parse.no_remainder_operator

Error % is not an operator; use Int.rem (the dividend's sign) or Int.mod (the divisor's).

Bynk has no % operator. Remainder is a method with its sign spelled out: a.rem(b) takes the dividend's sign (the C, Java and JavaScript %), a.mod(b) takes the divisor's (Python's %; use it for a cyclic index). When both operands are plain names or integer literals the error offers a .rem fix, never applied automatically: check that the sign is the one you want.

Example

fn parity(n: Int) -> Int {
n % 2 // ✗ there is no `%`
}
fn parity(n: Int) -> Int {
n.rem(2) // ✓ the dividend's sign, as `%` in C
}
fn slot(n: Int) -> Int {
n.mod(2) // ✓ the divisor's sign, as `%` in Python
}

In the Book

See also

  • Every code in its category, Parser, on the diagnostic index.
  • bynk explain bynk.parse.no_remainder_operator shows the same from the installed toolchain, without a network.