Skip to content
Playground(another site)

bynk.consumes.unit_not_consumed

Error A call to another unit's service is written in a file whose own consumes does not name that unit.

Imports are per file. A call to another unit's service (pay.charge(…), or through the alias of consumes pay as P) is in scope only in a file that itself consumes that unit, in any form, even when another file of the same context does. A call from a file that does not is an error; bynk check --fix=bynk.consumes.unit_not_consumed adds consumes <unit> to this file. The unit's wiring and deploy order still follow the union of its files' consumes.

Example

shop/checkout.bynk
consumes pay
service checkout {
on call() -> Effect[Int] by Caller {
pay.charge(1)
}
}
// shop/refund.bynk, another file of the same context
service refund {
on call() -> Effect[Int] by Caller {
pay.charge(2) // ✗ this file does not consume `pay`
}
}
consumes pay // ✓ each file consumes what it names

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.unit_not_consumed shows the same from the installed toolchain, without a network.