Skip to content
Playground(another site)

bynk.consumes.service_arity

Error A consumed service was called with the wrong number of arguments.

A cross-context call has the shape of the on call handler it reaches: one argument for each parameter. The consumed context owns that signature, so the caller adapts to it. Pass the arguments the handler declares (the note says where it is declared), or change the handler's parameters if the service needs different input.

Example

pay.bynk
context pay
service charge {
on call(amount: Int) -> Effect[Int] by Caller {
Effect.pure(amount)
}
}
// shop.bynk
context shop
consumes pay
service checkout {
on call() -> Effect[Int] by Caller {
pay.charge(1, 2) // ✗ `charge` takes one argument
}
}
service checkout {
on call() -> Effect[Int] by Caller {
pay.charge(1) // ✓ one argument for `amount`
}
}

In the Book

See also

  • The grammar rule it governs: consumes_decl.
  • Every code in its category, Consumes, on the diagnostic index.
  • bynk explain bynk.consumes.service_arity shows the same from the installed toolchain, without a network.